简体   繁体   English

Nhibernate 连接池问题

[英]Nhibernate Connection Pool Problems

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. 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 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)在准备 select TOP (@p0)
.... ……
an error occurred发生错误

We have to recycle the IIS app pool to stop 500 errors from being thrown after that.我们必须回收 IIS 应用程序池以阻止 500 错误之后被抛出。

Looking at the SQL Server we see:查看 SQL 服务器,我们看到:

select * from sys.dm_exec_sessions

... gives about 30 sessions with IDs above 51 (ie user sessions) ... 提供大约 30 个 ID 大于 51 的会话(即用户会话)

select * from sys.dm_exec_connections 

... gives around the same amount ...给出大约相同的数量

BUT

select @@connections

... gives results with 79022 ... 给出 79022 的结果

Is this indicating that the connections are never released?这是否表明连接永远不会被释放?

The Nhibernate sessions are for the lifetime of the request. Nhibernate 会话用于请求的生命周期。

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.您与 SQL 服务器的连接不能超过32767

@@CONNECTIONS also gives (my bold) @@CONNECTIONS也给出了(我的粗体字)

Returns the number of attempted connections, either successful or unsuccessful since SQL Server was last started.返回自上次启动 SQL 服务器以来尝试的连接数,无论是成功的还是不成功的。

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.或者您没有正确释放连接,并且您在回收 IIS 后正在检查 SQL 服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM