Linq to sql SQL Server“;网络相关或实例特定错误“;一天一次左右(困惑!)

Linq to sql SQL Server“;网络相关或实例特定错误“;一天一次左右(困惑!),linq-to-sql,sql-server-2008-r2,Linq To Sql,Sql Server 2008 R2,我们遇到了与…相同的错误 。。。除了在引用的StackOverflow Q中,一旦发生错误,他们需要重新启动SQL Server,而我们没有。我们每天会收到一次错误,或者每隔几天收到一次-错误发生后,一切都会好起来,直到下一次发生 这使我们认为这不是一个“忘记关闭连接”的问题。我们有一个中等繁忙的ASP.NET4.0WebForms/SQLServer2008R2应用程序;但我们可以肯定的是,我们没有超过数据库连接的最大数量 对这个问题有什么想法,或者有什么诊断方法吗?我想我会评论一下我们在这方

我们遇到了与…相同的错误

。。。除了在引用的StackOverflow Q中,一旦发生错误,他们需要重新启动SQL Server,而我们没有。我们每天会收到一次错误,或者每隔几天收到一次-错误发生后,一切都会好起来,直到下一次发生

这使我们认为这不是一个“忘记关闭连接”的问题。我们有一个中等繁忙的ASP.NET4.0WebForms/SQLServer2008R2应用程序;但我们可以肯定的是,我们没有超过数据库连接的最大数量


对这个问题有什么想法,或者有什么诊断方法吗?

我想我会评论一下我们在这方面的进展

虽然没有任何SQL Server文档/文章/博客提到此错误可能是由服务器繁忙引起的,但我发现一个名为Matt Neerincx的资深IT专业人士指出,它可能是,如下所示:

Possible reasons for this error include:

1. Poor network link from client to server.

2. Server is very busy (meaning high CPU) and cannot respond to new connection attempts.

3. Server is running out of memory (so high memory usage for SQL).

4. tcp-ip layer on client is over-saturated with connection attempts so tcp-ip layer rejects the connection.

5. tcp-ip layer on server side is over-staturated with connection attempts and so tcp-ip layer is rejecting new connections.

6. With SQL 2005 SP2 and later there could be a custom login trigger that rejects your connection.

You can increase the connect timeout to potentially alleviate issues #2, #3, #4, #5.  Setting a longer connect timeout means the driver will try longer to connect and may eventually succeed.

To determine the root cause of these intermittent failures is not super easy to do unfortunately.  What I normally do is start by examining the server environment, is the server constantly running in high CPU for example, this points to #2.  Is the server using a hugh amount of memory, this points to #3.   You can run SQL Profiler to monitor logins and look for patterns of logins, perhaps every morning at 9AM there is a flurry of connections etc...
因此,我们目前正在沿着这条路走下去——减少一些批处理查询中同时执行的查询数量,优化一些查询,等等

此外,在我们的应用程序连接字符串中,我们增加了连接超时,并将最小池大小设置为20(认为最好尝试确保应用程序可以获取一些现有的、未使用的连接,而不需要建立新连接)


此时此刻,已经将近48小时没有收到错误;这让我们充满希望。

您正在共享连接吗?我们没有指定任何共享配置-只是让所有默认设置都适用。这是我们的连接字符串(sans凭据;还要注意,我们的ADO.NET提供程序是System.Data.SqlClient):数据源=xxx\sql200840000;网络库=DBMSSOCN;初始目录=yyy;MultipleActiveResultSets=True;持久安全信息=True;连接超时=60我知道这个答案在2月22日(发布20天后)被接受,所以我假设问题已经解决了?您是否将其缩小到导致问题的特定问题?我们通过优化一些昂贵的查询(大多数SQL Server资源问题的罪魁祸首)以及将最小池大小设置为20,对其进行了分类。如前所述,这是为了确保池中始终有一些空闲的打开连接可用,以避免出现“由于SQL Server太忙而无法建立新连接”之类的错误。
Possible reasons for this error include:

1. Poor network link from client to server.

2. Server is very busy (meaning high CPU) and cannot respond to new connection attempts.

3. Server is running out of memory (so high memory usage for SQL).

4. tcp-ip layer on client is over-saturated with connection attempts so tcp-ip layer rejects the connection.

5. tcp-ip layer on server side is over-staturated with connection attempts and so tcp-ip layer is rejecting new connections.

6. With SQL 2005 SP2 and later there could be a custom login trigger that rejects your connection.

You can increase the connect timeout to potentially alleviate issues #2, #3, #4, #5.  Setting a longer connect timeout means the driver will try longer to connect and may eventually succeed.

To determine the root cause of these intermittent failures is not super easy to do unfortunately.  What I normally do is start by examining the server environment, is the server constantly running in high CPU for example, this points to #2.  Is the server using a hugh amount of memory, this points to #3.   You can run SQL Profiler to monitor logins and look for patterns of logins, perhaps every morning at 9AM there is a flurry of connections etc...