8
votes

I am getting this error very frequently but not consistently on 2 pages in an application which is in a production environment. I just have some screen shots of the error below.

Transaction(Process ID XX) was deadlocked on lock | communication buffer resources with another process and has been chosen as a deadlock victim. Rerun the transaction.

What should the approach be to resolve this error. The db server is SQL Server 2005.

5

5 Answers

3
votes

This article by Brad McGehee is a good place to start.

2
votes

You need to run a Deadlock profile trace while the errors are occurring. The article by Brad McGehee is a overview. You need to identify the two offending processes. After that, review the code in the two pages to see what SQL commands are being issued and how often. Most of the time, I have found that simply reviewing the SQL code being run and knowing how often it runs will quickly identify the conflict. Fixing it sometimes takes longer...

1
votes

You could do as the error message suggests and get the program to retry the transaction!

Depends very much on how "atomic" the transaction is though! i.e. If you were deadlocked its likly that some other process has succesfully updated the row you are interested in. Does it still make sense to apply the update to the row in htese circumstances?

At the very least present the user with a nicer error message ("Another user has changed the xxxx you were attempting to update. Please review the new values and try again.)