关于访问数据库异常:Timeout expired问题
MS SQL 2005+ASP.NET 2.0
目前这个平台已经稳定运行了2年多,从来没有出现过这样的错误.
最近因为机房扩充(原来只在电信放了服务器),现在在网通加了站点服务器(网通的站点程序是通过TCP/IP连接外网远程的数据库:Data Source=122.23.45.123,36782;Network Library=DBMSSOCN;Initial Catalog=Test;User ID=TestDBUser;Password=pwd324uyr 连接是没有任何问题),最近发现站点频繁报告这个异常.具体错误信息如下)
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
StackTrace: at FotoEver.SystemLibrary.ExceptionHandler.ThrowException(SystemLayer layer, Exception ex) in D:\WorkDir\VSS3\NewFEWebSiteDev\SystemLibrary\ExceptionHandler.cs:line 16
at FotoEver.DatabaseLibrary.DBHandler.ThrowException(Exception ex) in D:\WorkDir\VSS3\NewFEWebSiteDev\DBClient\DBHandler.cs:line 633
at FotoEver.DatabaseLibrary.DBHandler._ExecuteNonQuery() in D:\WorkDir\VSS3\NewFEWebSiteDev\DBClient\DBHandler.cs:line 131
at FotoEver.DatabaseLibrary.DBHandler.ExecuteNonQuery(String commandText, CommandType commandType, Hashtable parameterList) in D:\WorkDir\VSS3\NewFEWebSiteDev\DBClient\DBHandler.cs:line 119
at FotoEver.NewsLibrary.ArticleMgr.VisitCountPlusOne(Int32 ID) in D:\WorkDir\VSS3\NewFEWebSiteDev\NewsLibrary\ArticleMgr.cs:line 181
at FotoEver.UI.Fashion.EntRead.GetAritcleInfo()
at FotoEver.UI.Fashion.EntRead.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at FotoEver.BaseLibrary.PageBase.OnLoad(EventArgs e) in D:\WorkDir\VSS3\NewFEWebSiteDev\BaseLibrary\PageBase.cs:line 39
at FotoEver.BaseLibrary.PageBaseN.OnLoad(EventArgs e) in D:\WorkDir\VSS3\NewFEWebSiteDev\BaseLibrary\PageBaseN.cs:line 37
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Client Info:REMOTE_USER:; REMOTE_ADDR:116.19.79.134
我也使用SQL性能分析器跟踪了一段时间,结果发现Audit Logout事件狂多,并且Reads很大(I/0很大),但是cpu时间很正常,整个数据库服务器的内存和cpu都很正常,cpu维持在8%以下运行.但是就是不停的报告该异常,我也尝试着把Command.CommandTimeout = 60;sp_who2察看以后,发现Connection Pool也并没有到达最大连接,设置更大了一点,但是没有用.
很奇怪的是,当发生该异常的时候数据库就一个table好像被锁死了一样,查询该表就是一直处于等待状态,其他表查询都很快.大约3~4分钟后就自动好了.
所以很奇怪,网通没有加进来的时候,2年多从来没有发生过该异常,我开始怀疑是不是因为网通用tcp/ip连接数据库时,因为网络问题,导致连接不稳定造成数据库I/O被堵塞.
我发现,该异常90%发生在对该table进行查询的时候.
希望大家帮我想想办法,分数不是问题.
谢谢.