Skip to content

HibernateJpaDialect should warn about connection release mode other than ON_CLOSE (when upgrading from 4.0.x) [SPR-13269] #17860

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions