|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, November 22, 2012 2:43 AM
Points: 177,
Visits: 268
|
|
There is some deadlock appeared in the database, can any one tell me how to come out of deadlock situations. Rgards, Naveen
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, August 31, 2012 7:19 AM
Points: 225,
Visits: 419
|
|
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
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, November 22, 2012 2:43 AM
Points: 177,
Visits: 268
|
|
| how to clear the deadlocks, is it required to restart the sql server services or is anyother method.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, August 31, 2012 7:19 AM
Points: 225,
Visits: 419
|
|
| 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....
|
|
|
|
|
SSC-Insane
         
Group: General Forum Members
Last Login: Yesterday @ 2:27 PM
Points: 21,357,
Visits: 9,537
|
|
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.
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 7:38 AM
Points: 37,726,
Visits: 29,987
|
|
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 2008, MVP 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
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, August 31, 2012 7:19 AM
Points: 225,
Visits: 419
|
|
| 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....
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 7:38 AM
Points: 37,726,
Visits: 29,987
|
|
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 2008, MVP 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
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, February 03, 2011 3:00 AM
Points: 164,
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
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, June 27, 2012 1:03 PM
Points: 4,
Visits: 40
|
|
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
|
|
|
|