npgsql Leaking Postgres DB Connections: Way to monitor connections?
- by Alan
Background: I'm moving my application from npgsql v1 to npgsql v2.0.9. After a few minutes of running my application, I get a System.Exception: Timeout while getting a connection from the pool.
The web claims that this is due to leaking connections (opening a db connection, but not properly closing them).
So
I'm trying to diagnose leaking postgres connections in npgsql.
From the various web literature around; one way to diagnose leaking connections is to setup logging on npgsql, and look for the leaking connection warning message in the log. Problem is, I'm not seeing this message in the logs anywhere.
I also found utility that monitors npgsql connections, but it's unstable and crashes.
So I'm left manually inspecting code. For everyplace that creates an npgsql connection, there is a finally block disposing of it. For everyplace that opens a datareader, CommandBehavior.CloseConnection is used (and the datareader is disposed).
Any other places to check or can someone recommend a way to look for leaking pool connections?