How to handle the Trasaction Deadlock

  • Hi,

    I am getting the following error while executing a statement through JDBC.

    com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID 579) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

    The same statement is not giving any error when executed on DB2 or Oracle.

    The table which the statement is executed on, consists of 57 columns and I am updating 54 columns with the SQL Statement.

    Do I need to break up the table into 2 tables?

    Or

    Is it Ok to give the error message to user and ask the user to rerun the transaction? (There are no requirements as such from the client, I just want o know how the industry handles such transaction locking scenarios)

    Or

    Do I need to change the code?

    Thanks,

    TNV

  • Hi

    Check out the attached.

    Tanx 😀

  • Switch traceflag 1222 on. That will result in a deadlock graph been written to the error log every time a deadlock occurs. Post the result of that graph here.

    DBCC TRACEON(1222,-1)

    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
  • Is the deadlock occurring every time you execute the statement? If so, you've got a fundamental problem somewhere. If you can, in addition to getting the traceflag data as Gail outlines, post the query, & relevant data structures, including any triggers.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 4 posts - 1 through 3 (of 3 total)

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