sql server deadlock problem
Posted Chuck Lu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql server deadlock problem相关的知识,希望对你有一定的参考价值。
Event: Proc [Database Id = 12 Object Id = 525453146]
执行以下的sql语句,可以得到数据库名字和object名字
SELECT OBJECT_NAME(525453146) ,
DB_NAME(12);
https://www.cnblogs.com/rush/archive/2012/02/19/2358209.html
trace追踪的时候,选择deadlock:graph,deadlock:lock,deadlock:chain
Mentioned below are trace flags which are classical way to enable Deadlock trace in SQL Server Editions.
- Enable Trace Flag 1204 - Here data are captured in node level.
Dbcc traceon (T1204,-1)
- Enable Trace Flag 1222 - Here data is returned in XML Format. Also one can see the processes information also which are involved in deadlock.
DBCC Traceon (T1222,-1)
- Run SQL Profiler Trace to capture the Deadlock events.
This deadlock information can be viewed in SQL Server Error Logs and Trace Files.
DBCC TRACEON(1204, -1); DBCC TRACEON(1222, -1);
DBCC TRACEON - Trace Flags
Trace flags are used to set specific server characteristics or to alter a particular behavior.
For example, trace flag 3226 is a commonly used startup trace flag which suppresses successful backup messages in the error log.
Trace flags are frequently used to diagnose performance issues or to debug stored procedures or complex computer systems, but they may also be recommended by Microsoft Support to address behavior that is negatively impacting a specific workload.
All documented trace flags and those recommended by Microsoft Support are fully supported in a production environment when used as directed.
Note that trace flags in this list may have additional considerations regarding their particular usage, so it is advisable to carefully review all the recommendations given here and/or by your support engineer.
Also, as with any configuration change in SQL Server, it is always best to thoroughly test the flag in a non-production environment before deploying.
1204
Returns the resources and types of locks participating in a deadlock and also the current command affected. For more information, see this Microsoft Support article.
Scope: global only
SQL Server technical bulletin - How to resolve a deadlock
1222
Returns the resources and types of locks that are participating in a deadlock and also the current command affected, in an XML format that does not comply遵从 with any XSD schema.
Scope: global only
DBCC TRACESTATUS
Displays the status of trace flags.
DBCC TRACESTATUS(1204,-1); DBCC TRACESTATUS(1222,-1); DBCC TRACESTATUS(-1);
以上是关于sql server deadlock problem的主要内容,如果未能解决你的问题,请参考以下文章
VITAM POST MORTEM – ANALYZING DEADLOCKED SCHEDULERS MINI DUMP FROM SQL SERVER