某日,业务系统达到了15万数据,客户反映隔1个小时左右就出现无法连接到数据库,需要重新启动MS SQL Server才恢复正常,经错误跟踪发现以下错误:
“/XXX”应用程序中的服务器错误。
超时时间已到。在操作完成之前超时时间已过或服务器未响应。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 超时时间已到。在操作完成之前超时时间已过或服务器未响应。
源错误:
行 71: 行 72: 行 73: DataSet ds = db.ExecuteDataSet(dbCommand); 行 74: if (int.TryParse(db.GetParameterValue(dbCommand, "TotalPage").ToString(), out result)) 行 75: TotalPage = (int)db.GetParameterValue(dbCommand, "TotalPage");
|
源文件: XXX.DAL\Pager\DataPager.cs
行: 73
堆栈跟踪:
[SqlException (0x80131904): 超时时间已到。在操作完成之前超时时间已过或服务器未响应。] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1950890 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4846875 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392 System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33 System.Data.SqlClient.SqlDataReader.get_MetaData() +83 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +10 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +130 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +287 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +94 Microsoft.Practices.EnterpriseLibrary.Data.Database.DoLoadDataSet(DbCommand command, DataSet dataSet, String[] tableNames) +865 Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(DbCommand command, DataSet dataSet, String[] tableNames) +110 Microsoft.Practices.EnterpriseLibrary.Data.Database.LoadDataSet(DbCommand command, DataSet dataSet, String tableName) +103 Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteDataSet(DbCommand command) +111 .DAL.Pager.DataPager.GetPager2005(String TableName, String Fields, String OrderField, String sqlWhere, Int32 PageSize, Int32 PageIndex, Int32& TotalPage) in E:\Works\\Source\\.DAL\Pager\DataPager.cs:73 .BLL.Pager.DataPager.GetPager2005(String TableName, String Fields, String OrderField, String sqlWhere, Int32 PageSize, Int32 PageIndex, Int32& TotalPage) in E:\Works\\Source\\.BLL\Pager\DataPager.cs:44 Retiree_RetireeInfoSearchResult.BindGridView(String strWhere, Boolean isBind) in e:\Works\\Source\\.WebUI\Retiree\RetireeInfoSearchResult.aspx.cs:254 Retiree_RetireeInfoSearchResult.aspnetPager_PageChanged(Object src, EventArgs e) in e:\Works\\Source\\.WebUI\Retiree\RetireeInfoSearchResult.aspx.cs:272 Wuqi.Webdiyer.AspNetPager.OnPageChanged(EventArgs e) +97 Wuqi.Webdiyer.AspNetPager.OnPageChanging(PageChangingEventArgs e) +191 Wuqi.Webdiyer.AspNetPager.RaisePostBackEvent(String args) +155 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
|
版本信息: Microsoft .NET Framework 版本:2.0.50727.3634; ASP.NET 版本:2.0.50727.3634
问题分析:
1、数据量大,同时使用人数多,请求量大、同时存在多个应用系统导致服务器负担太大;
2、程序问题,没注意优化,或导致死循环
3、数据库配置的问题
4、IIS或程序配置的问题
解决方案:
1、修改web.config配置
加入
Pooling=True;Max Pool Size = 512
2、修改SQL Server配置
在服务器属性中修改连接数的限制,将远程查询超时值设置为0