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:
Referenced from: commits a1107af
0 votes, 5 watchers
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 classSessionTransactionData, methodresetSessionState.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.resetSessionStatethen gets again a connection (the same instance), but this time it is never released. This happens only ifresetConnectionistrue, which in turn happens for readonly transactions. So if this transaction is the outermost transaction then nobody closes the connection obtained inresetSessionState.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:
Referenced from: commits a1107af
0 votes, 5 watchers