Deadlock in SQL

  • I am getting below Deadlock Error:

    Transaction (Process ID 1900) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

    Is there any method to find what caused this deadlock in SQL?

  • You can look at the deadlock graph which is part of the system health extended event session.

    that will tell you what objects the two spids had along with the queries so you can investigate the deadlock.

  • Total agreement that the system_health Extended Event session is the way to go. Here's a sample query that shows how to pull deadlock information out. You can also use the Live Data Explorer window and filter for the deadlock events. That'll be a lot slower, but some people prefer guis to explore data.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • also keep in mind , if you are able to extract the deadlock xml (copy/past into a .xdl file), SentryOne PlanExplorer has a nice "replay" feature that shows the sequence to which the instance got to the deadlock state for that query.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply