Deadlocks

  • Does enyone know some native way to handle deadlocks in SQL Server, or some thirth party tool ?

    Is there any chance to catch or avoid deadlock before it happens ?

    How to analyze who was involved (I meen what processes) when it happend ?

  • Plz check this link:

    http://www.sql-server-performance.com/tips/deadlocks_p1.aspx

  • The best thing to do with deadlocks is find the cause and fix it. Typically deadlocks are caused by bad code, bad indexing or both.

    Set traceflag 1204 on and SQL will write the deadlock graph into the error log whenever a deadlock occurs. You can use that to find the cause of the deadlock

    DBCC TRACEON (1204,-1)

    or add -T1204 to SQL's startup parameters.

    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
  • The way to stop deadlocks is to trace them down and then fix the code so it doesn't allow deadlocks.

  • Adding to what Steve and Shaw said you have first track down the code involved in deadlock and then you need to change the code or tune the code to be very precise.

    Make use of steps mentioned under this link:

    http://blogs.msdn.com/bartd/archive/2006/09/09/Deadlock-Troubleshooting_2C00_-Part-1.aspx

    Make use of trace flag 1204 as Gail suggested. The above link is talking abbout 1222 as it is there in SQL 2005, rest of the steps are same.

    HTH,

    MJ

  • Thanks to all of you guys.

    I read all the links, and now I will start that flag.

    Then we will see.

Viewing 6 posts - 1 through 5 (of 5 total)

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