-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Default connection release mode inconsistent with Hibernate 5.1.1 [SPR-14548] #19116
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
Manuel Dominguez Sarmiento commented This is related to #18966 |
Juergen Hoeller commented Note that Hibernate did default to Our It seems that it was exactly Hibernate 5.1 where we missed the default change. From my perspective, the correct solution is to enforce Why specifically do you see such a significant difference between after-transaction and on-close? With standard |
Manuel Dominguez Sarmiento commented Thanks for your feedback Juergen. Upgrading to Hibernate 5.2.x has been so far a nightmare, because of the API changes and compatibility issues (not Spring's fault BTW). Our tests worked fine after working through all the issues, however our production systems crashed after upgrading. |
Juergen Hoeller commented You're certainly not the only ones to struggle with Hibernate 5.2 :-( Recent Hibernate upgrades have been rather painful all across the board. FWIW, our Spring Boot 1.4 curated dependencies stick with Hibernate 5.0.9 for the time being... not with 5.2.1 and not even with 5.1 (where we're not sure where it'll get properly maintained since there isn't any maintenance release yet). Hibernate 5.0.x is part of WildFly 10 / JBoss EAP 7, so it's arguably the current mainstream version. With Spring Framework 5, we're raising the baseline to Hibernate 5... but even there we're aiming for Hibernate 5.0+ and do not intend to require 5.2+ yet (which we would do if the upgrade story was more seamless and if JBoss EAP 7 would support it at that level). |
Juergen Hoeller commented We're enforcing |
Yanming Zhou commented https://hibernate.atlassian.net/browse/HHH-7412 |
Juergen Hoeller commented Indeed, it actually only changed back to In any case, our particular fix here only really applies to 5.1.1+: We seem to run against consistent |
Manuel Dominguez Sarmiento opened SPR-14548 and commented
We're using LocalSessionFactoryBuilder and when upgrading from [Hibernate 5.1.0 + Spring 4.2.5] to [Hibernate 5.2.1 + Spring 4.3.2] the effective connection release mode changed from "after transaction" to "on close". The Hibernate default for non-JTA environments has been "after transaction" for ages, since "on close" holds connections way too long. This caused major connection pool exhaustion which went unnoticed in our preproduction and test environments, but was hit immediately once our apps got real production load.
The defaults should be:
"after transaction" for non-JTA environments
"after statement" for JTA environments
At least this is what connection release mode "auto" (the default) has been doing in Hibernate for a long time.
Otherwise upgrading to latest Spring+Hibernate versions causes a major change in behavior and performance.
This can be resolved by explicitly configuring the following Hibernate property:
hibernate.connection.handling_mode=DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION
(see org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode which is new in Hibernate 5.2 - this used to be handled by the old hibernate.connection.release_mode property)
FYI "on close" ceased to be the default back in 2005:
https://hibernate.atlassian.net/browse/HHH-1038
Affects: 4.3.1, 4.3.2
Issue Links:
Referenced from: commits 3614369, 7d1c2f1, fad931d
0 votes, 6 watchers
The text was updated successfully, but these errors were encountered: