Spring Batch / PostgreSQL : "Cannot change transaction isolation level in the middle of a transaction." using defaultAutoCommit=false #7865
Labels
status: superseded
An issue that has been superseded by another
Uh oh!
There was an error while loading. Please reload this page.
Spring Boot 1.4.3 / JDK 8 / PostgreSQL Driver 9.4.1209
Using a Datasource (Tomcat JDBC in our case) configured with defaultAutoCommit=false leads to
This error is caused by SQL requests being ran out of a transaction by
JobLauncherCommandLineRunner#getNextJobParameters()
.PostgreSQL connection used are neither committed nor rollbacked and as such, are still considered "OPEN" by the PostgreSQL Driver. This connection is then returned to the pool.
The next request is made by Spring Batch using the same connection (the pool returned the same connection), but the transaction isolation needs to be changed due to the configuration defined in
AbstractJobRepositoryFactoryBean#initializeProxy()
configuration. This operation is forbidden by PostgreSQL since the connection is already open.A very simple reproducer is available here : https://gist.github.com/gdarmont/0b796aa06b86c37d147a6cded8065e96
You only need a PostgreSQL DB.
A small patch is available in PR #7866
Guillaume
The text was updated successfully, but these errors were encountered: