spring-projects / spring-batch

Spring Batch is a framework for writing batch applications using Java and Spring
http://projects.spring.io/spring-batch/
Apache License 2.0
2.74k stars 2.36k forks source link

ORA-08177 can't serialize access for this transaction #4725

Open prasanthks81 opened 5 days ago

prasanthks81 commented 5 days ago

Getting below ORA-08177 issue when multiple Spring batch jobs are triggered at the same time.

org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO BATCH_JOB_EXECUTION(JOB_EXECUTION_ID, JOB_INSTANCE_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, VERSION, CREATE_TIME, LAST_UPDATED)
                VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
]; SQL state [72000]; error code [8177]; ORA-08177: can't serialize access for this transaction

Property already added to set the Transaction isolation level as READ_COMMITTED

Versions used

prasanthks81 commented 1 day ago

Friendly reminder - Could you please provide an update on this?

fmbenhassine commented 1 day ago

Indeed, the issue should be resolved if you lower the transaction's isolation level.

However, the following is incorrect:

spring.batch.jdbc.isolation-level-for-create=READ_COMMITTED
spring.datasource.hikari.transaction-isolation=TRANSACTION_READ_COMMITTED

It should be:

spring.batch.jdbc.isolation-level-for-create=ISOLATION_READ_COMMITTED
spring.datasource.hikari.transaction-isolation=ISOLATION_READ_COMMITTED

There is a sample in the docs here: https://docs.spring.io/spring-batch/reference/job/configuring-repository.html#txConfigForJobRepository

Have you tried that?