Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


deadlock


deadlock

Author
Message
ekknaveen
ekknaveen
SSC Veteran
SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)

Group: General Forum Members
Points: 231 Visits: 343
There is some deadlock appeared in the database, can any one tell me how to come out of deadlock situations.
Rgards,
Naveen
Ramji29
Ramji29
Old Hand
Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)

Group: General Forum Members
Points: 311 Visits: 479
Naveen..
This is a very open questin.... to prevent this happening again.. you need to have understanding of your app and then you need to understand why it happened...

Below are some good links which you can refer to start your investigation...

http://msdn.microsoft.com/en-us/library/ms178104.aspx
http://www.sqlservercentral.com/Forums/Topic514877-146-1.aspx#bm515674

and here you need to provide as much as info you've to get to the point answer... as there can be 100s of reason for this to happen.... so post all the info you've or can gather... and lets see what we can make out of that....:-)

Tell me if this helps....

Rohit
ekknaveen
ekknaveen
SSC Veteran
SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)

Group: General Forum Members
Points: 231 Visits: 343
how to clear the deadlocks, is it required to restart the sql server services or is anyother method.
Ramji29
Ramji29
Old Hand
Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)

Group: General Forum Members
Points: 311 Visits: 479
See deadlock is automatically handeled by sql server we don't need to do anything except do our investigation to find out the root cause and taking preventive measures so that it never happens again....
Ninja's_RGR'us
Ninja's_RGR'us
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24937 Visits: 9671
Here's a very crud way for solving the problem once in a while.

exec sp_who2

Look at the blocked by column. That will list the spid that is most likely blocking everyone else.

then run KILL <put spid here>.

Then rerun sp_who2 again to see if the lock is resolved. Sometimes you need to do this 2-3 times.


This stops the immediate problem but it doesn't prevent it from happenning again.

Also keep in mind that all the transations that were running need to be restarted.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)

Group: General Forum Members
Points: 69749 Visits: 44947
SQL automatically resolves deadlocks as soon as it detects them. The error message that one gets is a notification that SQL detected the deadlock, resolved it by killing one session, and that session was yours.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Ramji29
Ramji29
Old Hand
Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)Old Hand (311 reputation)

Group: General Forum Members
Points: 311 Visits: 479
Although u need to be very cautious doing this on a production box... and not at all recommended unless you're facing some serious perfomance issues and you need to be aware of the impact as well....
GilaMonster
GilaMonster
SSC Guru
SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)SSC Guru (69K reputation)

Group: General Forum Members
Points: 69749 Visits: 44947
Ninja's_RGR'us (8/17/2010)
Here's a very crud way for solving the problem once in a while.

exec sp_who2

Look at the blocked by column. That will list the spid that is most likely blocking everyone else.

then run KILL <put spid here>.

Then rerun sp_who2 again to see if the lock is resolved. Sometimes you need to do this 2-3 times.


For blocking. Not for deadlocks.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


balaji.ganga
balaji.ganga
SSC-Enthusiastic
SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)SSC-Enthusiastic (198 reputation)

Group: General Forum Members
Points: 198 Visits: 656
Hi,

you need find out, if any blocks occurred in your database

use master
select * from sysprocesses where open_tran<>0

if any uncommitted transactions occurred in your database. blocks are created. Check it and fix
it.

With Regards
Balaji.G
Medhatithi Guha
Medhatithi Guha
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 44
Is this sql server 2005? Then run a profiler and capture the deadlock graph. Deadlock can occur because of a lot of reasons and the deadlock graph will give you a good idea where to start.

Also, just an observation. Most of the times while resolving deadlocks,we tend to look for X locks only. But please do examine the S locks also and let us just remember that a deadlock occurs on one (or more) resource. That resource can be a table itself, a row, a page, an index anything.
Even a simple select and then and update statement may lead to a deadlock.
So best idea would be to get hold of the deadlock graph first and then only can this problem be solved
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search