Posting Deadlock Data

  • I have deadlock data (trace flag stuff) and corresponding trace data. What is the best way to include that data in a post?

    David

  • What format's the deadlock info? If it's the text deadlock graph from the error log, just put it into a post. Otherwise zip and attach and explain what's in the zip file.

    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
  • Gail

    So that is what the attachment button is for:D;)

    Amazing what you learn when you scroll down. :w00t:

  • Ok, now that Gail has taught me how to post. 🙂

    The attached file shows the statement level trace for the two deadlocking spids plus the deadlock collision from the errorlog. A deadlock should be a conflict over two resources between two processes. This data shows that deadlock happened over one resource (dbo.order_detail). I would have expected this to block and resolve not deadlock.

    I'm getting multiple deadlocks a day on this procedure so it isn't a freak event.

    Any thoughts or suggestions would be appreciated.

  • What it looks like is that both processes had a shared lock (probably from a foreign key check earlier on) and then both wanted an exclusive. Neither can get the exclusive until the other releases the share... deadlock.

    Can you please post the procedure and indicate while is line 106, and also post the schema and indexes of the tables involved (at minimum the table that's actually been deleted on line 106)

    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
  • Gail

    Thanks for the insight. I hadn't thought of that at all. I think I'm guilty of over-engineer my joins in an effort to address the previous deadlock issue. The Delphi code (yes, I work in a delphi shop please don't laugh to hard) had been deadlocking on it's use of sp_executesql.

    Here is the code, any additional ideas would be appreciated.

  • Found it!!!

    Our freight calculation (delphi code) is doing a delete-insert every time freight is re-calculated. Freight has a item_number and we have three indexes that have the item number in the lead position. Every calculation is causing the indexes to be updated and affectively creating a hot spot where the deadlocks are happening.

    We are going to change the calculation to use insert-update instead. Tracing for the locks:acquired in our development environment help me get the answer.

    Gail, your point on the foriegn key got me going in a new direction and help find the contention point. Thanks for the assist.

    David

  • Excellent. Glad you came right.

    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

Viewing 8 posts - 1 through 7 (of 7 total)

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