Reputation: 1136
I run some tomcat application, use jndi connection pool. In some time connection pool stops to give connections and application hangs. Seems because some code receives connection and doesn't return it back to the pool. How can I monitor - which code does it ? More common - I want to see what all connections do at the moment.
I cannot change application. But I can adjust Tomcat, maybe add some interceptors.
Upvotes: 0
Views: 172
Reputation: 6548
Most connection pool implementations can be configured to detect connections that are not returned to the pool. E.g. for Tomcat's JDBC connection pool there are various configurations options for "abandoned connections" (connections for which the lease expired). If you search for "Abandoned" on this web-page, you'll find the options:
As mentioned on the web-page, these settings will add a little overhead but at least your application will not hang. When testing your application, set a low value for removeAbandonedTimeout
and a low value for maxActive
so that you can catch unreturned connections early.
Upvotes: 1
Reputation: 328800
I never use the connection pool API itself, I always wrap it in a helper.
That way, I can do this in the helper:
private Exception created = (0 == 1) ? new Exception() : null;
When I run into problems like yours, I just change one character (0
-> 1
) to have a stack trace of who created this instance in my debugger.
Upvotes: 0