Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is default isolation level of every method (of a spring batch job) for a spring integration and batch transaction set to SERIALIZABLE?

I have a spring integration + batch application.

The integration is used to read a file with a inboun channel adapter and call a batch job. The jobRepository is defined from : org.springframework.batch.core.repository.support.JobRepositoryFactoryBean

The transaction manager is org.springframework.orm.jpa.JpaTransactionManager.

When the application starts I don't know why but I read this strange kind of configuration:

[5860] [2012-03-12 17:40:47,267] D [main] [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] Adding transactional method [*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
[5860] [2012-03-12 17:40:47,267] D [main] [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] Adding transactional method [create*] with attribute [PROPAGATION_REQUIRES_NEW,ISOLATION_SERIALIZABLE]
[5860] [2012-03-12 17:40:47,267] D [main] [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] Adding transactional method [getLastJobExecution*] with attribute [PROPAGATION_REQUIRES_NEW,ISOLATION_SERIALIZABLE]

It seems that for default every jobmethod is configured with isolation SERIALIZABLE, but I didn't set it nowhere. Any idea how to set the default isolation level as ISOLATION_DEFAULT?

like image 377
Massimo Ugues Avatar asked Oct 09 '22 10:10

Massimo Ugues


1 Answers

It's SERIALIZABLE by default to prevent the same job instance being executed concurrently on 2 or more boxes. You can relax it if this is not a concern for you.

http://static.springsource.org/spring-batch/reference/html/configureJob.html#txConfigForJobRepository

The

isolation-level-for-create

attribute controls the propagation for create* and getLastJobExecution* methods

like image 137
Gary Russell Avatar answered Oct 12 '22 12:10

Gary Russell