Max pool .NET issue on ADO.NET and a quick solution

This is the error message you will get when pool is maxed out. Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Please try closing reader, command, connection by using close() and dispose() before using the method below. If the pooling is enabled in the application, sometime closing the connection by using Dispose() or Close() is just going to put the connection on the sleep mode (awaiting command). Even though there is connection closing statements on the application, on the database side, it was putting those connections on the sleep mode. As it built up, there were no more pool left, therefore it timed out. Solution is to add Pooling = False on the connection string of the application. This closes the connection as soon as dispose() is introduced. Hence no timeouts waiting for open pool.
Database=testdb; Server=testserver; uid=test; PWD=test; Pooling=False; Connect Timeout=30
I am not responsible if you use my solution and mess up something. Do at your own risk. Works for me here. Checking number of connections on database to see if max pool has reached …
--Total number of connections
SELECT DB_NAME(dbid) AS 'Database Name',
COUNT(dbid) AS 'Total Connections'
FROM sys.sysprocesses WITH (nolock)
WHERE dbid > 0
GROUP BY dbid;
 
--Connections
SELECT hostname, program_name, STATUS, cmd FROM sys.sysprocesses
WHERE DB_NAME(dbid) = 'Database Name goes here';
FacebookTwitterGoogle+Share

Leave a Reply

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

CAPTCHA Image

*