English 中文(简体)
死锁故障排除在Sql Server 2008
原标题:
  • 时间:2009-04-06 07:39:14
  •  标签:

我的网站似乎并t处理大量的游客,我相信这年代因为服务器太简单。

2个小时前我的网站是让很多支安打,我注意到3死锁发生错误,错误的是:

System.Data.SqlClient.SqlException : Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

我不知道为什么会这样……查看堆栈跟踪,我可以看到,这发生在一个select查询。

有人知道这个错误的原因可能是什么?

服务器正在运行Windows 2008和Sql server 2008。

最佳回答

写将阻止SQL服务器上读取,除非你有行启用版本控制。您应该使用<代码> sp_who2 > < /代码存储过程和一个SQL分析器跟踪。<代码> sp_who2 > < /代码会告诉你哪些进程阻塞,分析器会告诉你的最后一条语句是阻塞过程。

问题回答

SQL Server 2008多种方法来识别过程和查询参与死锁。

  1. If deadlocks are easy to reproduce,frequency is higher and you can profile SQL server (you have the access and performance cost on server when profiler is enabled) using SQL Profiler will give you nice graphical view of deadlock. This page has all the information you need to use deadlock graphs http://sqlmag.com/database-performance-tuning/gathering-deadlock-information-deadlock-graph

  2. 大多数时候繁殖死锁是困难的,或发生在生产环境中,我们不想把分析器,影响性能。

我将使用这个查询发生了死锁:

SELECT
  xed.value( @timestamp ,  datetime ) as Creation_Date,
  xed.query( . ) AS Extend_Event
FROM
(
  SELECT CAST([target_data] AS XML) AS Target_Data
  FROM sys.dm_xe_session_targets AS xt
  INNER JOIN sys.dm_xe_sessions AS xs
  ON xs.address = xt.event_session_address
  WHERE xs.name = N system_health 
  AND xt.target_name = N ring_buffer 
) AS XML_Data
CROSS APPLY Target_Data.nodes( RingBufferTarget/event[@name="xml_deadlock_report"] ) AS XEventData(xed)
ORDER BY Creation_Date DESC

我不会去的方向使用NOLOCK解决死锁。滑坡和隐藏原来的问题。





相关问题
热门标签