奇妙な断続的なSQL接続エラー、再起動時の修正、3〜5日後に戻る(ASP.NET)

StackOverflow https://stackoverflow.com/questions/428846

質問

何らかの理由で、3〜5日ごとにWebアプリが次のエラーでデータベースへの接続を開くことができなくなります。奇妙なことは、コンテナ(VPS)を再起動するだけです。通常の機能に復元されます。それから数日後かそこらで再び起こります。誰かがそのような問題を抱えたことはありますか?深夜のセキュリティログに、奇妙なADサーバーからの多くの匿名ログオンと、アムステルダムのIPからのいくつかに気づきました。それらが何を意味するのか、それが関連しているかどうかを正確に伝える方法がわかりません。

Server Error in '/ntsb' Application.
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

Source Error:

Line 11:        
Line 12:        
Line 13:        dbConnection.Open()
Line 14:        
Line 15:        


Source File: C:\Inetpub\wwwroot\includes\connection.ascx    Line: 13

Stack Trace:

[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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +248
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +245
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +475
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +260
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +2445449
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +2445144
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +354
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +703
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +54
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +2414696
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +92
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +1657
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +84
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +1645687
   System.Data.SqlClient.SqlConnection.Open() +258
   ASP.includes_connection_ascx.getConnection() in C:\Inetpub\wwwroot\includes\connection.ascx:13
   ASP.default_aspx.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\Default.aspx:16
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428


Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053 
役に立ちましたか?

解決

SQLサーバーへの許可された接続の数は固定リソースです。接続が正しく閉じられていないコードがどこかにあるように聞こえます。また、しばらくすると、新しいコードを開くことができなくなります。

他のヒント

最近、本番環境で同様の問題に直面しました。何度も「デバッグ」を行い、ダンプを分析して分析した結果、大きく断片化された大きなオブジェクトヒープがこれを引き起こしているという結論に達しました。 Ref http://msdn.microsoft.com/en-us/magazine/cc534993。 aspx 。要するに、アプリケーションのメモリが不足していて、接続を開くのに十分な連続スペースが残っていない可能性があります。 VMMap http://technet.microsoft.com/en-us/sysinternals/dd535533を使用できます。 使用可能な空き領域を識別するため。 AppPoolを定期的にリサイクルしていますか? AppPoolリサイクルは、アプリケーションを破棄し、ヘルプメモリを解放するため、関連する問題を解決します。

perfmonとプロファイラ(トレース)で基本情報を収集して、接続数、メモリ統計、その他の興味深いことを確認しようとしましたか?

"深夜のセキュリティログに、奇妙なADサーバーからの多くの匿名ログオン、およびアムステルダムのIPからのいくつかに気づきました。

システムに侵入しようとしている人がいるかのように聞こえますが、これらは閉じていない接続である可能性があります。問題を確認するには、perfmonとプロファイラーを使用することをお勧めします。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top