c# - Nhibernate 连接池问题

标签 c# sql-server nhibernate asp.net-mvc-3 database-connection

我们在使用 SQL Express 运行并处理多个基于 AJAX 的并发请求的 MVC3 Web 应用程序上遇到了 Nhibernate 的一些连接池问题。

每隔一段时间(中间几个小时)我们就会看到错误开始显示:

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.

然后加载

While preparing select TOP (@p0)
....
an error occurred

我们必须回收 IIS 应用程序池以阻止此后抛出 500 个错误。

看看我们看到的SQL Server:

select * from sys.dm_exec_sessions

...给出大约 30 个 ID 大于 51 的 session (即用户 session )

select * from sys.dm_exec_connections 

...给出大约相同的数量

但是

select @@connections

...给出 79022 的结果

这是否表明连接永远不会释放?

Nhibernate session 在请求的生命周期内有效。

有没有人有过类似的经验,或者可以为我们指明正确的方向?

非常感谢

理查德

最佳答案

你不能拥有更多 32767连接到 SQL Server。

@@CONNECTIONS也给(我的粗体)

Returns the number of attempted connections, either successful or unsuccessful since SQL Server was last started.

不是当前连接

我怀疑您的池设置不正确,所以用得太快了。

或者您没有正确释放连接并且在回收 IIS 后检查 SQL Server。

关于c# - Nhibernate 连接池问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6643124/

相关文章:

c# - 仅在登录页面上设置 SSL 页面

sql-server - SQL Alchemy 检查连接

nhibernate - 如果表中没有索引,如何配置 NHibernate 映射到数组?

NHibernate 3 分页和确定总行数

c# - Linq to SQL 和 Linq to Entities 中的投影

c# - MouseEnter 和 MouseLeave 事件未在用户控件中引发

c# - 我永远无法预测 XMLReader 的行为。有什么理解技巧吗?

mysql - Erlang模块调用mysql存储过程

c# - 寻找一种在运行时操作 .Net CIL 的方法

sql - 查询 SQL Server 时出错