Chapter 42. Tracing the deadlock
A deadlock has to be one of the most frustrating error messages that SQL Server can produce. Little information is given as to what went wrong, and the only advice the error message gives is “Rerun the transaction.” It appears that there’s no way to find the root cause and to prevent the mysterious error from occurring.
In truth, there are ways to find information on exactly what happened to cause a deadlock and, with that information, in most cases it’s possible to fix the root cause and prevent the error completely.
At its simplest, a deadlock refers to a locking situation that, if no outside action is taken, will never resolve itself. It occurs when two or more processes have a lock on a resource and then try to acquire a lock on the resource held by the other process, or when two or more processes hold shared locks on a resource and attempt to convert them to exclusive locks. Figure 1 illustrates an example of a deadlock scenario.