我的asp.net应用程序每天都运行良好.
直到上个月,我的网站开始在Sqlsession状态服务器上遇到2-3次问题
跟随:
Blockquote
System.Web.HttpException Exception of type ‘System.Web.HttpException’ was thrown. at System.Web.HttpAsyncResult.End() at System.Web.SessionState.SessionStateModule.EndAcquireState(IAsyncResult ar) at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) ================================================== Exception: System.Web.HttpException Unable to connect to SQL Server session database. at System.Web.SessionState.SqlSessionStateStore.ThrowSqlConnectionException(SqlConnection conn,Exception e) at System.Web.SessionState.SqlSessionStateStore.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo) at System.Web.SessionState.SqlSessionStateStore.GetConnection(String id,Boolean& usePooling) at System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext context,String id,Boolean getExclusive,Boolean& locked,TimeSpan& lockAge,Object& lockId,SessionStateActions& actionFlags) at System.Web.SessionState.SqlSessionStateStore.GetItemExclusive(HttpContext context,SessionStateActions& actionFlags) at System.Web.SessionState.SessionStateModule.GetSessionStateItem() at System.Web.SessionState.SessionStateModule.PollLockedSessionCallback(Object state) ================================================== Exception: System.InvalidOperationException Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at System.Web.SessionState.SqlSessionStateStore.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo)
然后我开始查看我的会话数据库服务器并在我的sql客户端中执行了“exec sp_who”,它在结果中找到了很多AspState操作的记录.
我不知道是什么原因造成这种问题,因为我们没有改变任何严肃的事情
在out应用程序中,只修复了一些bug.
以下是我的Web应用程序环境的详细信息:
asp.net 3.5(从1.1转换)…工作得非常好
2个服务器场具有会话状态的sqlmode.
有没有人知道这个问题或者有任何想法进行调查?
谢谢
这听起来像是你正在用尽池中所有可用连接的情况.浏览您的代码并确保像这样设置数据库连接:
using (SqlConnection cn = new SqlConnection(connectionString))
{
using (SqlCommand cm = new SqlCommand(commandString,cn))
{
cn.Open();
cm.ExecuteNonQuery(); // or fill a dataset,etc.
}
}
一旦退出此“使用”语句,连接将自动关闭.
执行此操作将清除应用程序中的所有其他数据库连接,并且State Server连接将能够在需要时进行连接.