使用进程外会话状态的ASP.NET应用程序中SQL Server的连接问题

我在由4台Windows 2003计算机组成的服务器群中部署了几个ASP.NET应用程序。每个应用程序在IIS中使用单独的应用程序池和虚拟目录。它们严重依赖于在单个SQL Server 2000上进行进程外持久化的会话(<sessionstate mode=“sqlserver”。../>)。应用程序是根据.NET 3.0编译的,但.NET 3.5 SP1安装在服务器上

每个web服务器每秒接收大约10个请求。偶尔我会在日志中看到一些异常:

System.Data.SqlClient.SqlException:从服务器接收结果时发生传输级别错误。(提供程序:TCP提供程序,错误:0-信号量超时时间已过期。)
位于System.Data.SqlClient.SqlConnection.OneError(SqlException异常,布尔断开连接)
位于System.Data.SqlClient.SqlInternalConnection.OneError(SqlException异常,布尔断开连接)
位于System.Data.SqlClient.TdsParser.ThroweException和Warning(TdsParserStateObject stateObj)
位于System.Data.SqlClient.TdsParserStateObject.ReadsInError(TdsParserStateObject stateObj,UInt32错误)
位于System.Data.SqlClient.TdsParserStateObject.ReadSni(dbasynchresult asynchresult,TdsParserStateObject stateObj)
位于System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()处
位于System.Data.SqlClient.TdsParserStateObject.ReadBuffer()处
位于System.Data.SqlClient.TdsParserStateObject.ReadByte()处
在System.Data.SqlClient.TdsParser.Run(RunBehavior RunBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj)
位于System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds、RunBehavior、String ResetOptions String)
位于System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior、RunBehavior RunBehavior、Boolean returnStream、Boolean async)
位于System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior、RunBehavior RunBehavior、Boolean returnStream、String方法、DbAsyncResult)
位于System.Data.SqlClient.SqlCommand.InternalExecuteOnQuery(DbAsyncResult结果、字符串方法名、布尔sendToPipe)
位于System.Data.SqlClient.SqlCommand.ExecuteOnQuery()处
位于System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext上下文、字符串id、SessionStateStoreData项、对象锁定id、布尔newItem)

或其他:

System.Data.SqlClient.SqlException:将请求发送到服务器时发生传输级别错误。(提供程序:TCP提供程序,错误:0-远程主机已强制关闭现有连接。)
位于System.Data.SqlClient.SqlConnection.OneError(SqlException异常,布尔断开连接)
位于System.Data.SqlClient.SqlInternalConnection.OneError(SqlException异常,布尔断开连接)
位于System.Data.SqlClient.TdsParser.ThroweException和Warning(TdsParserStateObject stateObj)
位于System.Data.SqlClient.TdsParserStateObject.WriteSni()处
位于System.Data.SqlClient.TdsParserStateObject.WritePacket(字节刷新模式)
位于System.Data.SqlClient.TdsParserStateObject.ExecuteFlush()处
在System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[]rpcArray,Int32 timeout,Boolean inSchema,SqlNotificationRequest notificationRequest,TdsParserStateObject stateObj,Boolean isCommandProc)
位于System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior、RunBehavior RunBehavior、Boolean returnStream、Boolean async)
位于System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior、RunBehavior RunBehavior、Boolean returnStream、String方法、DbAsyncResult)
位于System.Data.SqlClient.SqlCommand.InternalExecuteOnQuery(DbAsyncResult结果、字符串方法名、布尔sendToPipe)
位于System.Data.SqlClient.SqlCommand.ExecuteOnQuery()处
位于System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext上下文、字符串id、SessionStateStoreData项、对象锁定id、布尔newItem)

或者另一个:

System.Data.SqlClient.SqlException:超时已过期。操作完成前已过超时时间,或者服务器没有响应。
位于System.Data.SqlClient.SqlInternalConnection.OneError(SqlException异常,布尔断开连接)
位于System.Data.SqlClient.TdsParser.ThroweException和Warning(TdsParserStateObject stateObj)
位于System.Data.SqlClient.TdsParserStateObject.ReadsInError(TdsParserStateObject stateObj,UInt32错误)
位于System.Data.SqlClient.TdsParserStateObject.ReadSni(dbasynchresult asynchresult,TdsParserStateObject stateObj)
位于System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()处
位于System.Data.SqlClient.TdsParserStateObject.ReadBuffer()处
位于System.Data.SqlClient.TdsParserStateObject.ReadByte()处
在System.Data.SqlClient.TdsParser.Run(RunBehavior RunBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj)
位于System.Data.SqlClient.SqlDataReader.ConsumerMetadata()处
在System.Data.SqlClient.SqlDataReader.get_MetaData()处
位于System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds、RunBehavior、String ResetOptions String)
位于System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior、RunBehavior RunBehavior、Boolean returnStream、Boolean async)
位于System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior、RunBehavior RunBehavior、Boolean returnStream、String方法、DbAsyncResult)
位于System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior、RunBehavior RunBehavior、Boolean returnStream、String方法)
位于System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior,String方法)
位于System.Data.SqlClient.SqlCommand.ExecuteReader()处
位于System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext上下文、字符串id、布尔getExclusive、布尔和锁定、时间跨度和锁定、对象和锁定id、SessionStateActions和操作标志)

这些错误每天发生几次,持续约1-2分钟,然后消失。有没有人遇到过这样的问题?为了进一步追踪这个问题,你能建议我做什么?在我看来,这更像是网络问题,而不是应用程序问题。可能是SQL Server上的某些设置无法处理如此多的并发连接吗?如有任何建议,将不胜感激


更新:

我通过对应用程序执行主要更新来减少会话中存储的对象的数量和大小,从而解决了这个问题

传输级错误通常与与与sql server的连接中断有关。。。通常是网络

当sql查询运行时间过长时,通常会引发超时过期

因此,我将对到Sql Server的链接进行故障排除,然后监视以查看哪些查询超时

听起来好像SQL作业正在运行,备份?这可能是锁定表或重新启动服务

发表评论