What is the difference between a deadlock and normal blocking, and how do you tell them apart when troubleshooting a slow application?
Short answer
Blocking happens when one transaction simply has to wait for another to release a lock, which resolves naturally once the first transaction finishes, while a deadlock is a genuine cycle where neither transaction can ever finish without one of them being forcibly rolled back…
Advertisement
AModel answer
Blocking happens when one transaction simply has to wait for another to release a lock, which resolves naturally once the first transaction finishes, while a deadlock is a genuine cycle where neither transaction can ever finish without one of them being forcibly rolled back, meaning blocking causes delay while a deadlock causes an actual error that the application must handle.
Example
-- Blocking: Transaction 2 waits, then proceeds once Transaction 1 commits -- Deadlock: Transaction 1 and 2 wait on each other, so SQL Server cancels one
Real-world example
A support team initially assumes a slow report is caused by a deadlock, but after checking sys.dm_exec_requests finds it is actually just normal blocking behind a long running transaction that eventually completes on its own.
Likely follow-ups
- How do you check whether a currently slow query is experiencing blocking rather than an actual deadlock?
- Does blocking ever escalate into an actual deadlock?
Related topics