-
Notifications
You must be signed in to change notification settings - Fork 38.5k
HibernateJpaDialect should warn about connection release mode other than ON_CLOSE (when upgrading from 4.0.x) [SPR-13269] #17860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Juergen Hoeller commented This is an effect triggered by the changes behind #13599 / #16559. Do you by any chance specify a connection release mode other than ON_CLOSE? In this case you would indeed get a reset executed on the current Connection handle returned by the Hibernate Session, with no explicit close call. See the javadoc of I suppose we should try to identify such scenarios and not try to set/reset the read-only status on the Connection correspondingly, based on the connection release mode in the current Session handle, analogous to what we do in Juergen |
Oliver Becker commented Yes, first we had an explicit AFTER_TRANSACTION configuration, then we tried AUTO, which doesn't solve the problem either. |
Juergen Hoeller commented So just double-checking, does it work with ON_CLOSE for you? Note that Hibernate's Juergen |
Oliver Becker commented Hmm, Hikari keeps reporting "Apparent connection leak detected", even for ON_CLOSE. |
Juergen Hoeller commented Could you double-check the effect with ON_CLOSE there? I'm surprised that there would be any kind of connection leak in that case... Juergen |
Oliver Becker commented Sorry for not responding earlier. It turned out that these leaking connections in the case of ON_CLOSE were indeed a bug in our application (hidden by using AFTER_TRANSACTION). We have fixed it and now everything works correct with ON_CLOSE (resp. AUTO) and the latest Spring release. Nevertheless, with AFTER_TRANSACTION the above-mentioned problems still exist (but they're not a blocker for us anymore). Oliver |
Juergen Hoeller commented
Juergen |
Uh oh!
There was an error while loading. Please reload this page.
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.resetSessionState
then gets again a connection (the same instance), but this time it is never released. This happens only ifresetConnection
istrue
, 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
The text was updated successfully, but these errors were encountered: