Are SQL Server timeouts logged?

我的梦境 提交于 2019-12-09 08:59:02

问题


Are SQL Server timeouts (SELECT queries, in particular) logged in the ERRORLOG file?

Background is a customer with a web site having occasional "Request timeout" messages, looking to me assuming that the timeout is caused by a database timeout. There are no timeout errors in the ERRORLOG in question.


回答1:


No. You will need to use SQL Profiler. A standard trace with the Lock Timeout event and Deadlock Graph events should do it.

  • Lock:Timeout Event Class

  • Deadlock Graph Event Class

Hardware aside (such as enough RAM and fast drives, and appropriate placement of Data and Log files on the appropriate RAID configurations) most timeouts are caused by not having a sufficently 'good' set of indexes for your workload.

Do you have index maintenance plans scheduled regularly?




回答2:


SQL Server timeouts are initiated from the client-side as Attention Events and are not recorded in the SQL Server Error Log.

You can monitor for Attention Events using:

  • SQL Server Profiler
  • The DMV sys.dm_os_ring_buffers



回答3:


You could also use Event Notifications that get raised on the timeout and deadlock events. After it fires, you can write it to a table and or send yourself an email.

I've shown the general technique here:

Immediate deadlock notifications without changing existing code 🕗

July 18, 2008

This way you don't have to run Profiler; which can impact performance.



来源:https://stackoverflow.com/questions/295299/are-sql-server-timeouts-logged

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!