ADO.NET and deadlocks

  • Hello everyone,

    Anyone knows how deadlock victims are handled in ADO.NET?

    Is an exception raised?

    Thank's

    Carl

  • you have to (set lock_timeout) in SQL server query analyzer .. which sets the maximum amount of time that SQL Server allows a transaction to wait for the release of a blocked resource..

    if you do this and deadlock happened .. then a victim killed after lock_timeout has passed .. and i think an error message will be reterned to u


    Alamir Mohamed
    Alamir_mohamed@yahoo.com

  • deadlocks occur right away.  The setting of the lock timeout may just increase (or decrease) the likelyhood of a deadlock. 

    It throws an sqlexception.  in the errors collection look for the number property in the sqlerror class.

  • Hello Jared,

    As you mentionned we are not interested at all to rely on lock timeout for the deadlock handling.

    But we did two little programs to test a deadlock and the exception that is thrown is for the "timeout expired" not for a deadlock "victim".

    Have you tried that and are you able to catch a deadlock exception?

    Best regards,

    Carl

  • Actually our code is written in OLEDB which does catch it.  I would run sql

    profiler to see whether you are truly getting a deadlock or a lock timeout.  Its possible that the lock_timeout interval is too small based on your test programs to generate a deadlock.

  • of course the "timeout expired" is a deadlock message .. because one had gone into Lock waiting until its lock_timeout is finished.

    but the problem you may face is that the message "timeout expired" is happened for may reasons such as deadlock, ...... , etc .

    but it is mostly come when deadlock happens.


    Alamir Mohamed
    Alamir_mohamed@yahoo.com

  • Alamir,

    "Timeout expired" and deadlock are not the same.

    You can reach a timeout without having a deadlock situation.

    Those are two different concepts.

    Carl

  • Jared,

    you were right, the developper who made those two programs has made mistakes.

    Now we have the correct Exception: Transaction (Process ID %d) was deadlocked on {%Z} resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

    Best regards and sorry for that mistake.

    Carl

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

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