-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)type: bugA general bugA general bug
Milestone
Description
Ric Klaren opened SPR-7368 and commented
We experienced deadlocks in our product while load testing. The issue occurs when mixing Hibernate Sessions with JdbcTemplate code. What basically happens:
- The session in view filter creates a new Hibernate Session.
- The HibernateTransactionManager registers a JDBC datasource in the thread local map using the real class.
- Somewhere in a service call (and transaction) the user details are requested via the JdbcUserDetailsManager (from spring security) which is implemented as a JdbcTemplate. The JdbcTemplate has a JDK proxy of the datasource. This leads to a lookup in the thread local map with the proxy in stead of the real data source. Since TransactionSynchronizationUtils.unwrapResourceIfNecessary() does not unwrap JDK proxies the lookup fails. As a result the existing connection is not reused and a new connection is requested from the connection pool.
This deadlocks when the connection pool has no connections left.
(Checked the code up to 3.0.3 Release in which this is also present)
Affects: 3.0 GA
Metadata
Metadata
Assignees
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)type: bugA general bugA general bug