Using spring-batch, I have 2 datasources : one for the spring batch called centralDataSource
and one for the business called localDataSource
.
I've set the isolation level to ISOLATION_READ_UNCOMMITTED to avoid problems with concurrent transactions as below.
@Bean
public Job myJob(Step firstStep,
Step secondStep,
JobCompletionNotificationListener listener,
JobRepository customJobRepository) {
return jobBuilderFactory.get("my-job")
.repository(customJobRepository)
.listener(listener)
.incrementer(new RunIdIncrementer())
.start(firstStep)
.next(secondStep)
.build();
}
@Bean
public JobRepository customJobRepository(
@Qualifier("centralDataSource") DataSource centralDataSource,
@Qualifier("centralTransactionManager") PlatformTransactionManager centralTransactionManager)
throws Exception {
JobRepositoryFactoryBean factoryBean = new JobRepositoryFactoryBean();
factoryBean.setDatabaseType("ORACLE");
factoryBean.setDataSource(centralDataSource);
factoryBean.setTransactionManager(centralTransactionManager);
factoryBean.setIsolationLevelForCreate("ISOLATION_READ_UNCOMMITTED");
return factoryBean.getObject();
}
I still have Application run failed
with SQLException: ORA-08177: can’t serialize access for this transaction
.
I don't understand why. There are not even 2 concurrent spring batch jobs running at the same time. Jobs are run sequentially so why does this happen and how can I solve it ?
Can anyone help me ?