we are having some connection pool issues with Nhibernate on an MVC3 web application which is running with SQL Express and dealing with multiple concurrent AJAX based requests.
Every so often (hours in between) we see errors starting which show:
NHibernate.Util.ADOExceptionReporter
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.
then a load of
While preparing select TOP (@p0)
….
an error occurred
We have to recycle the IIS app pool to stop 500 errors from being thrown after that.
Looking at the SQL Server we see:
select * from sys.dm_exec_sessions
… gives about 30 sessions with IDs above 51 (i.e. user sessions)
select * from sys.dm_exec_connections
… gives around the same amount
BUT
select @@connections
… gives results with 79022
Is this indicating that the connections are never released?
The Nhibernate sessions are for the lifetime of the request.
Does anyone have any experience of anything like this or can point us in the right direction?
Many thanks
Richard
You can’t have more then 32767 connection to SQL Server.
@@CONNECTIONS also gives (my bold)
Not current connection
I suspect that your pool is not set up correctly so it’s exhausted too quickly.
Or you are not releasing connections correctly and you’re checking SQL Server after you recycle IIS.