Unclosed connection - Connection Pool debugging SQ

2019-05-07 20:26发布

问题:

We have a suspect application leaving a connection open. Just wondering on the debugging tools for this, as to whether anyone has any good tools for isolating this, commercial or otherwise.

I've Googled but only seem to bring up articles that describe the problem - not the steps for a solution.

This is the best article I've seen so far. - Others welcome.

Anyone have any products that isolate the problematic code? Profilers which perform this sort of thing, or any other advice to add?

回答1:

You can always check the Activity Monitor on SQL Server to see if the application is keeping the connection open.

It's under the Management node in SQL Server Management Studio. It will show you the host, application, user, number of open transactions, etc. for any applications that are connected to the database.



回答2:

Which language are you using? Under Java's BoneCP connection pool (http://jolbox.com) there is support to detect exactly this by watching for when a thread terminates and printing out a stack trace of the location where the connection was opened but not closed.

You can probably implement something very similar yourself though of course it will slow things down if you intend to use this in production.