question

ChaitanyaKiranBuduguru-7986 avatar image
0 Votes"
ChaitanyaKiranBuduguru-7986 asked SeeyaXi-msft answered

Facing Deadlocks

There are deadlocks happening. As i enabled TF 1222, I can see the XML format. How to resolve it, please help

sql-server-general
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SeeyaXi-msft avatar image
1 Vote"
SeeyaXi-msft answered

Hi ChaitanyaKiranBuduguru-7986,

Use the SQL Server system stored procedures sp_who and sp_lock, you can view the lock situation in the current database, and then you can view which resource is locked according to the objectID.
Check that the spid is in the wait state, and then use "kill spid". Of course, this is only a temporary solution. We cannot always troubleshoot deadlocks and Kill sp in the user's production environment when we encounter deadlocks. We should consider how to avoid deadlocks.
Note: You can also use other system management views, the purpose is to find out the blocked process.
Then kill this process.

As for XML file, It is very easy to find out what action is currently being performed, which can be used to analyze the real cause of deadlock.
Please refer to this blog:
https://www.sqlshack.com/understanding-the-xml-description-of-the-deadlock-graph-in-sql-server/
The XML description of the deadlock provides a ton of additional information which makes troubleshooting deadlocks a lot easier. So instead of just using the deadlock graph, be sure to also look at the XML description of the graph.

Best regards,
Seeya


If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.