1

Took my SpringBatch built on Spring Boot project into a higher environment and I am not receiving a odd error: Caused by: org.springframework.dao.CannotSerializeTransactionException: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_EXECUTION_PARAMS(JOB_EXECUTION_ID, KEY_NAME, TYPE_CD, STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL, IDENTIFYING) values (?, ?, ?, ?, ?, ?, ?, ?)]; ORA-08177: can't serialize access for this transaction ; nested exception is java.sql.SQLException: ORA-08177: can't serialize access for this transaction

I was running this against a Oracle database locally which was running: Oracle Enterprise 11g R2 v11.2.0.3

Put it into our "Test" environment which is running oracle: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

Any idea how to correct this? Want to demo to my team.

Thanks,

Dean Clark
  • 3,770
  • 1
  • 11
  • 26
CardsFan
  • 75
  • 1
  • 11
  • I would also not be opposed to not writing the data to the SPRING BATCH* tables if this is an option. It seemed that once I added oracle as a DS then it started automatically writing the meta data. – CardsFan Jan 11 '18 at 16:04
  • Possible duplicate of [Spring Batch ORA-08177: can't serialize access for this transaction when running single job, SERIALIZED isolation level](https://stackoverflow.com/questions/22364432/spring-batch-ora-08177-cant-serialize-access-for-this-transaction-when-running) – Michael Minella Jan 23 '18 at 16:42

1 Answers1

3

Sounds like an issue with your transaction isolation. The default is ISOLATION_SERIALIZABLE which is fairly aggressive.

Try changing your isolationLevelForCreate to ISOLATION_READ_COMMITTED in your JobRepository and see how that goes.

Dean Clark
  • 3,770
  • 1
  • 11
  • 26
  • 2
    I added the below code to my @Configuration file and it worked. `@Configuration @EnableBatchProcessing public class BatchConfiguration { protected JobRepository createJobRepository() throws Exception { JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); factory.setDataSource(dataSource); factory.setTransactionManager(transactionManager); factory.setIsolationLevelForCreate("ISOLATION_READ_COMMITTED"); return factory.getObject(); } @Autowired private PlatformTransactionManager transactionManager; ` – CardsFan Jan 11 '18 at 17:13