Deadlocks

  • Is it possible to have 0 deadlocks in a busy multiuer system?

    Is it normal to have around 10 deadlocks daily?

    Please share your experiences.

  • What do you mean by 0 Deadlocks...

    According to my MEAN Knowledge, if it is NO (0) deadlocks.. yes it is always possible and Good to have NO Deadlocks...on a SQL Server system.

    This means your system is not highly transactional Or is very well maintained:::: i.e. Database is normalized and All Queries are using proper HINTS and your server settings are optimized.

    Correct me if i am WRONG.

    if you see a deadlock that is in place for a long time, make sure, it is not running a HUGE Query.. then kill the SPID associated with it...

    (Before taking this step.. make sure the SPID is not performing any Data Changes in the DB)

  • if a deadlock block your system too long time,then delete it.


    [font="Arial"]MCDBA, MCITP (DB Dev, DB Admin), MCSE,MCTS, OCA 10g[/font]

  • Mani Singh (7/8/2008)

    if you see a deadlock that is in place for a long time, make sure, it is not running a HUGE Query.. then kill the SPID associated with it...

    (Before taking this step.. make sure the SPID is not performing any Data Changes in the DB)

    sqlservercenter (7/8/2008)


    if a deadlock block your system too long time,then delete it.

    You don't ever have to worry about killing processes involved in a deadlock. SQL has a deadlock detector built in, if it detects an unresolvable locking condition (a deadlock) it will pick one of the processes involved and automatically kill it.

    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
  • Suresh B. (7/8/2008)


    Is it possible to have 0 deadlocks in a busy multiuer system?

    Is it normal to have around 10 deadlocks daily?

    It is not normal to have 10 deadlocks a day on any system, 0 is what you want and it is not impossible to achieve.

    If you have frequent deadlocks then you either have badly written SQL code, poor indexes or both.

    Enable traceflag 1204 OR 1222 to get the deadlock graph written into the error log. That should help you locate the queries involved in the deadlock.

    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
  • Check the ISOLATION LEVELS for more info.

  • Mani Singh (7/8/2008)

    (0) deadlocks.. yes it is always possible

    ... is very well maintained:::: i.e. Database is normalized...

    GilaMonster (7/8/2008)

    It is not normal to have 10 deadlocks a day on any system, 0 is what you want and it is not impossible to achieve.

    If you have frequent deadlocks then you either have badly written SQL code, poor indexes or both.

    This is what I was looking for.

    Thanks Gail Shaw and Mani Singh.

  • When I started in my current job, they had upwards of 120 deadlocks a day..... If I had know that before I accepted the job..... Let's just say it was very indicative of some issues.

    I have gotten it down to about 6-7 per day at this point, and those that are left are trapped, since I started trapping them for a couple of stored procedures they have not affected the client. Unfortunatly rewriting the code so they do not happen is just about impossible at this point. But I am looking into it =)

    THe main thing that solved the problem here was actually to put an index on a lookup table.... Go figure!

  • Adding to Anders.

    My Current job, there is a Application "Maximo" which deals with SHOP Floor Order Entry system. There are 100 People in the Steel Mill loggin into the application through CITRIX, which come down the Database and they generate Huge amount of Deadlocks/locking/blocking Scenarios Daily.. I have check them to use HINTS in their SQL Reports and Application CODE. Also WOrked aound ISOLATION LEVELS.. and SEPRATED their READONLY Data from READ/WRITE using FileGroups and also Seprated their REPORTs to USE, a logged shipped version of Database.. which gets updated twice daily... This is SQL server 2000 SP4.

  • I'm with Gail... but a bit more stringent on the subject. If you have any deadlocks, something is wrong in the code somewhere and you need to fix it. Finding the cause can sometimes be a bit troubling but everytime you have a deadlock, there's a rollback which takes time and that also possibly means some lost data. Finding and repairing code that causes deadlocks should be a top priority for every DBA.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Adding to it:

    sometimes, the Deadlocks might resolve by themselves in time, but if you kill a long waiting deadlock, you might end up with a Phantom Process/lock and it stays there, unless you have the option to restart the SQL Service.

  • I believe you're thinking of blocking.... deadlocks do not resolve themselves in a nice manner... there is always a "victim" that get's rolled back... always.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Mani Singh (7/9/2008)


    Adding to it:

    sometimes, the Deadlocks might resolve by themselves in time, but if you kill a long waiting deadlock, you might end up with a Phantom Process/lock and it stays there, unless you have the option to restart the SQL Service.

    For the third or fourth time, No! As I said earlier in this thread

    You don't ever have to worry about killing processes involved in a deadlock. SQL has a deadlock detector built in, if it detects an unresolvable locking condition (a deadlock) it will pick one of the processes involved and automatically kill it.

    The definition of a deadlock is an unresolvable locking condition. Hence left alone they will never resolve themselves. That said, you will almost never be able to kill a process involved in a deadlock. The SQL deadlock detector is a lot faster than you are.

    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
  • Yes I ment was Blocked not DEADLOCK.

    Yes again i agree with GILA.

  • Yes it is possible to have no deadlocks, however, in this day and age most code is written badly, however, if you do get deadlocks there is no need to worry as the system will detect this and kill one of the processes.

    Terry

Viewing 15 posts - 1 through 15 (of 47 total)

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