JBOSS – Which threads have a database connection checked out of the pool?

We had an issue in ATG which was eventually traced to deadlocked sessions on checkout, each of which was attempting to decrement inventory for SKU’s in opposite order.

In other words, session one wanted to decrement inventory for A and B, and session 2 wanted to decrement inventory for SKU’s B and A.

Session 1 locked A, but couldn’t lock B, and session 2 locked B, but couldn’t lock A.

The only way we could track this down was to look at the evaporating pool of connections to the database.  When we did this, we saw the issue immediately.

  1. On the jmx-console of the server of interest, enabled debug on the jboss.jca CachedConnectionManager component
  2. Invoke the listInUseConnections bean method on the CachedConnectionManager component
  3. You will see a stack trace for each thread that has a connection checked out of the pool
  4. Look for a pattern in the stack traces for which class may be leaking connection handles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.