Created attachment 923329 [details]
1 instance of the leaked connection with ccm=true debug=true
Description of problem:
The hibernate afterCompletion method isn't closing the connection from the reaper thread and thus returns with a connection handle of 1. IJ then does not return the connection during afterCompletion due to the non 0 connection handle and the connection is leaked.
Tested the theory using 'hibernate.jta.track_by_thread = false' which gives Hibernate the ability to close connections from the Reaper thread to prove the issue. This, however, doesn't work as a solution due to concurrency issues.
Version-Release number of selected component (if applicable):
EAP 6.x & Hibernate 4.1.x / 4.2.x
Steps to Reproduce:
Note: These steps reflect the method by which this can be reproduced 100% of the time, not the real world scenario in which this occurs at random.
1. Thread outside the current transaction blocks for update on a row
2. Thread inside a transaction finds and updates the row which is blocked until the transaction times out.
3. With CCM, you see IJ000100, without, connection is leaked.
Connection is leaked from the pool permanently.
No connection leak.
Fixed for EAP 6.4.0.
Fixed by Hibernate 4.2.16.Final upgrade https://bugzilla.redhat.com/show_bug.cgi?id=1121629
Verified in EAP 6.4.0.DR11 / Hibernate 4.2.16.Final-redhat-1.