Estranho erro de conexão SQL intermitente, correções na reinicialização, volta depois de 3-5 dias (ASP.NET)

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

Pergunta

Por alguma razão a cada 3-5 dias nosso aplicativo web perde a capacidade de abrir uma conexão com o db com o seguinte erro, o estranho é que todos nós temos que fazer é reiniciar o recipiente (que é um VPS) e ele é restaurado para a funcionalidade normal. Em seguida, alguns dias mais tarde ou mais isso acontecer novamente. Alguém já teve esse problema um? Tenho notado um monte de anônimos logons no registo de segurança no meio da noite do nosso servidor AD que é estranho, e também alguns de um IP em Amesterdão. Não estou certo como dizer o que exatamente eles querem dizer ou se ele está relacionado ou não.

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 
Foi útil?

Solução

O número de conexões permitidas para o servidor SQL é um recurso fixo. Parece que você tem um lugar código que não está fechando sua conexão corretamente, e após um período que não é possível abrir mais novos.

Outras dicas

Nós recentemente enfrentou um problema semelhante no nosso ambiente de produção e depois de muitas rodadas de ging "DebugDiag" e analisar o lixeiras chegamos à conclusão de que uma grande pilha de objetos altamente fragmentada, estava causando isso. Ref http://msdn.microsoft.com/en-us/magazine/cc534993. aspx. Em suma, a sua aplicação pode ter executado com falta de memória e não tem espaço contiguos suficiente para conexões abertas. Você pode usar VMMap http://technet.microsoft.com/en-us/sysinternals/dd535533 com a finalidade de identificar o espaço livre disponível. Você está reciclando seus AppPools regularmente? Apppool reciclar lágrimas para baixo a aplicação e libera qualquer memória ajuda, portanto, resolve todos os problemas relacionados.

Você já tentou recolher informações básicas com perfmon e profiler (traço) para ver quantas conexões são feitas, estatísticas de memória e outras coisas interessantes?

"Tenho notado um monte de anônimos logons no registo de segurança no meio da noite do nosso servidor AD que é estranho, e também alguns de um IP em Amesterdão."

soa como se você poderia ter alguém tentando invadir seu sistema e talvez estas são as conexões que não estão fechando. I como a sugestão de usar perfmon e profiler para ver o problema.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top