Mor*_*oll 2 c# asp.net iis-7 sql-server-2008
几天前我注意到我的Web应用程序给了我一个异常超时到期的SQL.
我清理了几个存储过程,花了更多的CPU并重新启动SQL Server服务,我的应用程序开始工作,因为它是在快速和没有任何延迟之前.三四个小时后我再次检查它,我无法加载一个页面,而不是它给我的异常超时到期.我检查过服务器CPU是好的一切看起来很好.我在同一个IIS 7下有一些其他网站,它们运行良好,没有任何例外.我再次重新启动SQL Server服务,我的应用程序再次恢复正常.我认为它看起来像SQL服务器数据库上的问题,但我不知道如何解决它.
因此,每当我遇到异常时,我只是重启sql服务,但当然这不是最好的方法.请帮我解决这个问题.
这是我得到的一个例外.
消息:抛出了类型'System.Web.HttpUnhandledException'的异常.来源:System.Web内部异常:System.Data.UpdateException:更新条目时发生错误.有关详细信息,请参阅InnerException.---> System.Data.SqlClient.SqlException:超时已过期.操作完成之前经过的超时时间或服务器没有响应.该语句已终止.在System.Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔breakConnection)在System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔breakConnection)在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)在系统System.Data.SqlClient上的System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString)中的.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj) System.Data.SqlClient上的System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String方法,DbAsyncResult结果)中的.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async). SqlCommand.InternalExecuteNonQuery(DbAsyncResult结果,Str ING方法名,布尔sendToPipe)在System.Data.SqlClient.SqlCommand.ExecuteNonQuery()在System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator翻译,EntityConnection连接,字典
2 identifierValues, List1 generatedValues)在System.Data.Mapping. Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager,IEntityAdapter adapter)---内部异常堆栈跟踪结束---在System的System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager,IEntityAdapter适配器). Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)在System.Data.Objects.ObjectContext.SaveChanges(布尔acceptChangesDuringSave)在System.Data.Objects.ObjectContext.SaveChanges()在BCSCDomain.Domain.DataLayer.OtherDataLayer.UpdateHitCounter(的Int32 hlistid ,Int32 hcounterid)在BuyCarandSellCar.UsedCarProfilePage.HitCounter()at BuyCarandSellCar.UsedCarProfilePage.Page_Load(Object sender,EventArgs e)at System.Web.Util.CalliHelpe r.EventArgFunctionCaller(IntPtr的FP,对象O,对象吨,EventArgs e)上System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发件人,EventArgs e)上在系统System.Web.UI.Control.OnLoad(EventArgs的发送). Web.UI.Control.LoadRecursive()在System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)堆栈跟踪:在System.Web.UI.Page.HandleError(例外e)上的System.Web.UI. System.Web.UI.Page.ProcessRequestWithNoAssert上的System.Web.UI.Page.ProcessRequest()处的System.Web.UI.Page.ProcessRequest(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)的Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)位于c:\ Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root中的ASP.usedcarlistings_profilepage_aspx.ProcessRequest(HttpContext context)中的System.Web.UI.Page.ProcessRequest(HttpContext context)上的HttpContext上下文\ 79794658\835d6695\App_Web_k mrmpdbb.16.cs:在System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()在System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔逻辑completedSynchronously)线0
好吧,首先,它是导致问题的功能"UpdateHitCounter",但你不知道这是一个原因还是一个效果.您的查询超出了分配完成的配置时间.
每当您的数据库性能不佳时,可以在其上运行的广泛笔划方法是将Sql Profiler附加到它,然后针对结果执行索引调整向导.
如果您想采用更加严格的分类方法,您可以限制探查器仅记录完成时间超过x秒的查询,无论您认为x应该是什么.如果没有任何显示,我通常从5开始并从那里开始工作.这是该主题的入门读物.
识别长时间运行的查询后,在本地副本中执行它们并检查执行计划.这是一本入门书,但要开始寻找"桌面扫描".
最终,您的数据库不是最理想的,或者您的硬件不符合流量.这几乎肯定是第一个,这两种方法应该让你顺利.
| 归档时间: |
|
| 查看次数: |
11952 次 |
| 最近记录: |