2012-01-18 9 views
4

我々はthis StackOverflow Qと同じエラーが発生している...SQL Serverの「ネットワーク関連またはインスタンス固有のエラー」一日に一回かそこら(困惑!)

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) 
    at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) 
    at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) 
    at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) 
    at System.Data.SqlClient.SqlConnection.Open() 
    at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user) 
    at System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe() 
    at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode() 
    at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) 

...エラーが発生したら、SQL Serverを再起動する必要があります - そうしないでください。このエラーは、1日に1回、または数日に1回発生します。エラーが発生してから次回発生するまでは問題ありません。

これは「接続を閉じるのを忘れた」問題ではないと考えています。私たちは適度に忙しいASP.NET 4.0 WebForms/SQL Server 2008 R2アプリケーションを持っています。しかし、データベース接続の最大数を超えていないということは非常に肯定的です。

この問題に関するすべての考え、または診断する方法はありますか?

+1

接続をプールしていますか? –

+0

私たちはプーリング設定を指定しません - すべてのデフォルトを適用させるだけです。データソース= xxx \ sql2008,40000;ネットワークライブラリ= DBMSSOCN;初期カタログ= yyy; MultipleActiveResultSets = True;セキュリティ情報を保持する= True;接続タイムアウト= 60 –

答えて

2

私はこの進歩についてコメントしたいと思います。

SQL Serverのドキュメント/記事/ブログのどれもが、このエラーがサーバ忙しによって引き起こされる可能性があることに言及しないが、私はいくつかは、ITがマット・Neerincxという名前のプロに味付けforum postingは次のように、できることを述べました:

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... 

だから我々は現在、この道を歩いている - 私たちのバッチクエリの一部で同時に実行するクエリの#を減らし、私たちのクエリの一部を最適化する、など

をまた、中我々の接続タイムアウトを増やし、Min Pool Sizeを20に設定しました(新しい接続を確立する必要はなく、既存の使用されていない接続でアプリケーションを確保することをお勧めします)。

この時点では、エラーを受け取ることなくほぼ48時間が経過しています。私たちは非常に有望なものになっています

関連する問題