This article describes how to collect data for troubleshooting SQL deadlocks. Solutions 1 and 2 describe two different methods on how to collect data for a deadlock issue. The methods either enable specific trace flags to collect the logs, or use the SQL Profiler trace tool. You only have to use one method.
Information about what a deadlock is, and how it differs from blocking.
A deadlock occurs when two processes compete for exclusive access to a resource. But, one process is unable to obtain exclusive access to the resource because the other process prevents it. The result is a standoff, where neither process can continue. The only way out of a deadlock is for one of the processes to be closed. The SQL Server automatically detects when deadlocks occur, and kills one of the processes known as the victim.
Blocking occurs when:
- One process (UserA) tries to acquire a lock on a database object
- A second process (UserB) already has an incompatible lock on the same or parent object. The object can be a table, page, or row.
In the above situation, UserA can't access the object until UserB is finished with the object and has released it.
There’s a natural progression of events going on during a transaction. The transaction places locks on several resources because it needs to protect the referential integrity and database consistency. These locks block other transactions from acquiring locks on the same resources. The locks remain in place until the transaction with the lock is removed. The lock is released when either the transaction completes or is rolled back. These actions (locking and blocking) are normal events within the SQL Server and are to be expected. But, if you have a long running transaction, it can create long term blocking in the database, which prevents other work from going on. And, if two different transactions enter into a deadlock situation, SQL Server closes one of the transactions so that the system isn’t locked up.
If you notice a few deadlocking errors, it’s unlikely to lead to any noticeable issues within the ePO console. These rare intermittent events can most likely be safely ignored. If many deadlock errors occur, collect additional information about the deadlock errors with the steps in this article. We can then investigate any problems further.