从池中获取连接之前超时时间已过 - 但池未满

发布于 2024-11-11 18:11:09 字数 1297 浏览 4 评论 0原文

我什至讨厌提起这个,因为有数百页的页面在讨论这个错误,可以追溯到 7-8 年前……但是,我不太明白这一点。

我在服务器 A 上运行一个报表服务,该服务连接到服务器 B 上的 SQL Server 2008 R2。两台服务器都运行 Windows Server 2008。该报表服务是多线程的,每个报表一次最多运行 10 个报表。
我的连接字符串如下:

Data Source=ServerB;Initial Catalog=DBName;trusted_connection=YES;Connection Timeout=0;Max Pool Size=500;

如您所见,我已将连接超时设置为 0 以等待连接直至其可用,并将最大池大小设置为 500 b/c 我想确保池对于我来说不会太小多线程服务。该错误通常仅在服务启动且有报告队列等待处理时才会显示。

显然,要做的第一件事就是查找泄漏连接.. 必须有未关闭的连接导致池填满,对吗?不 - 看起来游泳池永远不会填满。

过去几个小时我在服务器上运行性能监视器来观察“.NET Data Provider for SqlServer”,并且 NumberOfPooledConnections 从未超过 20 左右。我还在 SQL Server 上运行 perfmon 来监视“SQLServer:General Statistics”,并且 UserConnections 永远不会超过 50。在此期间,我通过手动重新启动服务导致报告此错误 2 或 3 次。

我还能寻找什么?还有什么会导致这个错误? 完整的错误消息是:

System.InvalidOperationException: 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.
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()

谢谢, 斯蒂芬

I hate even bringing this up b/c there are so many hundreds of pages talking about this error dating back 7-8 years... However, I cant quite figure this out.

I have a report service running on server A which connects to SQL Server 2008 R2 on Server B. Both servers are running Windows Server 2008. The report service is multi-threaded and runs up to 10 reports at a time each on its own thread.
My connection string is as follows:

Data Source=ServerB;Initial Catalog=DBName;trusted_connection=YES;Connection Timeout=0;Max Pool Size=500;

As you see, I have set the connect timeout to 0 to wait for a connection until its available, and max pool size to 500 b/c I wanted to make sure the pool was not too small for my multi-threaded service. The error typically only shows up when the service starts and there is a queue of reports waiting to be processed.

So obviously, the first thing to do is look for leaking connections.. there have to be connections that are not being closed that are causing the pool to fill up, right? Nope -looks like the pool never fills up.

I have spent the last several hours running Performance Monitor on the server watching ".NET Data Provider for SqlServer" and the NumberOfPooledConnections never gets above 20 or so. I also have perfmon running on the SQL server watching "SQLServer:General Statistics" and UserConnections never goes above 50. During this time, I have caused this error to be reported 2 or 3 times by manually restarting the service.

What else can I look for? What else would cause this error?
Full error message is:

System.InvalidOperationException: 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.
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()

Thanks,
Stephen

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一身软味 2024-11-18 18:11:09

这是已知错误,如此处所示

由 Microsoft 发布于 2008 年 8 月 15 日上午 11:31
感谢您的反馈。该修复已提交到下一个主要 .Net 版本的源分支。

This is known bug as shown here

Posted by Microsoft on 8/15/2008 at 11:31 AM
Thanks for your feedback. The fix was submitted to the source branch of the next major .Net release.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文