3

出于某种原因,每 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 
4

4 回答 4

2

允许与 sql server 的连接数是固定资源。听起来您在某个地方的代码没有正确关闭它的连接,并且在一段时间之后您无法打开任何新的代码。

于 2009-01-09T17:06:33.853 回答
1

我们最近在生产环境中遇到了类似的问题,经过多轮“调试诊断”和转储分析,我们得出的结论是,很大程度上是碎片化的大型对象堆导致了这种情况。参考http://msdn.microsoft.com/en-us/magazine/cc534993.aspx。简而言之,您的应用程序可能内存不足并且没有足够的连续空间来打开连接。您可以使用 VMMap http://technet.microsoft.com/en-us/sysinternals/dd535533来识别可用空间。您是否定期回收您的 AppPools?AppPool 回收会拆除应用程序并释放任何帮助内存,从而解决任何相关问题。

于 2011-07-19T15:52:39.657 回答
0

您是否尝试过使用 perfmon 和分析器(跟踪)收集基本信息,以查看建立了多少连接、内存统计信息和其他有趣的事情?

于 2009-01-09T17:01:45.750 回答
0

“我在半夜从我们的 AD 服务器注意到安全日志中有很多匿名登录,这很奇怪,还有一些来自阿姆斯特丹的 IP。”

听起来好像你可能有人试图闯入你的系统,也许这些是没有关闭的连接。我喜欢使用 perfmon 和 profiler 来查看问题的建议。

于 2009-01-09T19:19:04.943 回答