1

我们有一个每晚执行 DBCC CheckDB 的 sql 代理作业。本周它在运行时开始出现故障。错误消息说存在死锁。

我们无法确定导致死锁的原因。因此,我们昨晚在下班时间重新启动了服务器,然后再次运行该作业,但仍然失败。

我们想知道是什么导致了这种情况发生。我们如何才能看到导致死锁的原因?

环境: SQL Server 2005

SQL 代理作业代码:

truncate table master..tbl_dbccresults;
insert into master..tbl_dbccresults
exec master..sp_msforeachdb @command1 = 'dbcc checkdb (?) with tableresults';

错误详情:

Executed as user: xxxxx\xxxxxx. Transaction (Process ID 76) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. 

[SQLSTATE 40001] (Error 1205)  DBCC execution completed. If DBCC printed error messages, contact your system administrator.
[SQLSTATE 01000] (Error 2528)  DBCC execution completed. If DBCC printed error messages, contact your system administrator. 
[SQLSTATE 01000] (Error 2528)  DBCC execution completed. If DBCC printed error messages, contact your system administrator. 
[SQLSTATE 01000] (Error 2528)  DBCC execution completed. If DBCC printed error messages, contact your system administrator. 
[SQLSTATE 01000] (Error 2528)  DBCC execution completed. If DBCC printed error messages, contact your system administrator. 
[SQLSTATE 01000] (Error 2528)  DBCC execution completed. If DBCC printed error messages, contact your system administrator. 
[SQLSTATE 01000] (Error 2528).  The step failed.
4

1 回答 1

1

要解决 SQL Server 死锁问题,您最好在服务器上启用 -1222 跟踪标志,以便将死锁信息记录在 SQL Server 错误日志中,供您进一步调查。您也可以使用 SQL Server 探查器来跟踪死锁事件。我会推荐以下关于解决 SQL Server 死锁问题的串行博客文章,请参阅:http: //blogs.msdn.com/b/bartd/archive/2006/09/09/deadlock-troubleshooting_2c00_-part-1.aspx

于 2013-06-06T14:31:49.637 回答