Search code examples
springoracle-databasespring-batch

spring-batch: getting SQL concurrency error on table BATCH_JOB_INSTANCE at start of job


Using a fairly recent version of spring-batch (5.1.0) we've had some runtime errors when two batches in separate linux processes kick off at the same time.

The error occurs within the spring-batch code that inserts into BATCH_JOB_INSTANCE.

Exception in SpringApplication.run()
org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO BATCH_JOB_INSTA
NCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION)
        VALUES (?, ?, ?, ?)
]; SQL state [72000]; error code [8177]; ORA-08177: can't serialize access for this transaction

I understand this to be a problem where the data in the BATCH_JOB_INSTANCE table is changing at the same time that spring-batch is trying to write to it.

What I don't understand is what the user of spring-batch is supposed to do about this. I would think that this should be a framework issue rather than a user issue.

Thanks for any enlightenment and / or pointers.

-alan


Solution

  • The question seems to be addressed here as well:

    Spring Batch ORA-08177: can't serialize access for this transaction when running single job, SERIALIZED isolation level

    You can set a different isolationLevelForCreate, recommended to be READ_COMMITTED.

    https://docs.spring.io/spring-batch/reference/job/configuring-repository.html#txConfigForJobRepository