HI WELCOME TO Sirees

SQL Server deadlock analysis and prevention

Leave a Comment

In this we will discuss how to read and analyze sql server deadlock information captured in the error log, so we can understand what's causing the deadlocks and take appropriate actions to prevent or minimize the occurrence of deadlocks.


The deadlock information in the error log has three sections
SectionDescription
Deadlock VictimContains the ID of the process that was selected as the deadlock victim and killed by SQL Server.
Process ListContains the list of the processes that participated in the deadlock.
Resource ListContains the list of the resources (database objects) owned by the processes involved in the deadlock

Process List : The process list has lot of items. Here are some of them that are particularly useful in understanding what caused the deadlock.
NodeDescription
loginnameThe loginname associated with the process
isolationlevelWhat isolation level is used
procnameThe stored procedure name
InputbufThe code the process is executing when the deadlock occured

Resource List : Some of the items in the resource list that are particularly useful in understanding what caused the deadlock.
NodeDescription
objectnameFully qualified name of the resource involved in the deadlock
owner-listContains (owner id) the id of the owning process and the lock mode it has acquired on the resource. lock mode determines how the resource can be accessed by concurrent transactions. S for Shared lock, U for Update lock, X for Exclusive lock etc
waiter-listContains (waiter id) the id of the process that wants to acquire a lock on the resource and the lock mode it is requesting

To prevent the deadlock that we have in our case, we need to ensure that database objects (Table A & Table B) are accessed in the same order every time.

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.