加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

在ASP.NET应用程序中使用out-of-process会话状态的SQL Server的

发布时间:2020-12-15 18:56:05 所属栏目:asp.Net 来源:网络整理
导读:我有几个ASP.NET应用程序部署在一个农场的4 Windows 2003机器。每个应用程序在IIS中使用单独的应用程序池和虚拟目录。它们严重依赖于在单个SQL Server 2000( sessionstate mode =“sqlserver”... /)上持久化的会话。应用程序是针对.NET 3.0编译的,但是.NET
我有几个ASP.NET应用程序部署在一个农场的4 Windows 2003机器。每个应用程序在IIS中使用单独的应用程序池和虚拟目录。它们严重依赖于在单个SQL Server 2000(< sessionstate mode =“sqlserver”... />)上持久化的会话。应用程序是针对.NET 3.0编译的,但是.NET 3.5 SP1安装在服务器上。

每个Web服务器接收大约10个请求/秒。每隔一段时间我在日志中得到一些例外:

System.Data.SqlClient.SqlException: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider,error: 0 - The semaphore timeout period has expired.)
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception,Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj,UInt32 error)
   at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult,TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
   at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
   at System.Data.SqlClient.TdsParserStateObject.ReadByte()
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,Boolean returnStream,Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method,DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result,String methodName,Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context,String id,SessionStateStoreData item,Object lockId,Boolean newItem)

或其他:

System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider,error: 0 - An existing connection was forcibly closed by the remote host.)
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.WriteSni()
   at System.Data.SqlClient.TdsParserStateObject.WritePacket(Byte flushMode)
   at System.Data.SqlClient.TdsParserStateObject.ExecuteFlush()
   at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray,Int32 timeout,Boolean inSchema,SqlNotificationRequest notificationRequest,TdsParserStateObject stateObj,Boolean isCommandProc)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,Boolean newItem)

或另一个:

System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception,TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior,String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()
   at System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext context,Boolean getExclusive,Boolean& locked,TimeSpan& lockAge,Object& lockId,SessionStateActions& actionFlags)

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

更新:

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

解决方法

传输级错误通常链接到连接到sql服务器被破坏…通常网络。

超时超时通常在sql查询运行时间过长时抛出。

所以我会排除故障的链接到您的Sql Server,然后监视,以查看什么查询是超时。

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读