Description
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:
- 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
- Doc: HibernateJpaVendorAdapter's "prepareConnection" may interfere with Hibernate 5.1+ in a JTA environment [SPR-14957] #19524 Doc: HibernateJpaVendorAdapter's "prepareConnection" may interfere with Hibernate 5.1+ in a JTA environment
- Database.SQL_SERVER should set more recent Hibernate dialect with Spring 4.3.x [SPR-15255] #19820 Database.SQL_SERVER should set more recent Hibernate dialect with Spring 4.3.x
Referenced from: commits 3614369, 7d1c2f1, fad931d
0 votes, 6 watchers