Description
Oliver Becker opened SPR-13269 and commented
We have a Spring MVC web application with Hibernate 4.3.10 as JPA provider and HikariCP 2.3.9 as our data source.
After updating Spring to the latest 4.1 version we noticed connection leaks (reported by Hikari). These leaking connections always belong to readonly transactions, more specific the outermost transaction must be readonly (annotated as @Transactional(readonly=true)
)
After some debugging the relevant code seems to be in org.springframework.orm.jpa.vendor.HibernateJpaDialect
, inner class SessionTransactionData
, method resetSessionState
.
The point is that this method is called from cleanupTransaction
, i.e. after the transaction has been committed and the corresponding connection has been released already. resetSessionState
then gets again a connection (the same instance), but this time it is never released. This happens only if resetConnection
is true
, which in turn happens for readonly transactions. So if this transaction is the outermost transaction then nobody closes the connection obtained in resetSessionState
.
I cannot really believe that there is such a serious bug present for already 7 minor releases - so what am I doing wrong? Where is the reset connection supposed the be released?
Affects: 4.1.7
Issue Links:
- Compatibility with Hibernate ORM 5.0 GA [SPR-13002] #17594 Compatibility with Hibernate ORM 5.0 GA
- readOnly transaction doesn't work with JPA and Hibernate 4 [SPR-8959] #13599 readOnly transaction doesn't work with JPA and Hibernate 4
- Isolation support for JPA with Hibernate EntityManager 4 [SPR-11942] #16559 Isolation support for JPA with Hibernate EntityManager 4
- JDBC Connection to reset not identical to originally prepared Connection with Hibernate 5.2 [SPR-14393] #18966 JDBC Connection to reset not identical to originally prepared Connection with Hibernate 5.2
Referenced from: commits a1107af
0 votes, 5 watchers