Contact us
Insights

Reading a blocking chain

When everything stalls at once, one session is often holding up the rest. How to find it and fix the cause, not the symptom.

The problem

Everything stops at once

Users report that the system has frozen: orders won’t save, reports spin, and the warehouse screens time out. The server isn’t busy. Instead, one session holds a lock that another needs, a third waits on the second, and soon dozens are queued. Restarting the application or killing sessions at random clears it for now, but without finding the head of the chain it will happen again.

Terms

What you’re looking at

Blocked session

A session waiting for a lock that another session holds.

Blocking session

The session holding that lock. It may itself be blocked by another.

Head blocker

The session at the top of the chain that isn’t waiting on anyone. This is the one to investigate.

Wait type and resource

What the blocked session is waiting for, and on which table, page, or row.

Investigating

How to read the chain

Step 1 of 4

  1. Query sys.dm_exec_requests for sessions with a blocking_session_id, or use a monitoring tool.

  2. Follow each blocking session up the chain until you reach one that isn’t blocked.

  3. Its last statement, the program and user, how long its transaction has been open, and whether it’s waiting for the application.

  4. Killing a session rolls back its work, which can take as long as it took to do. Know what you’re rolling back first.

Common causes at the head

The head blocker is often doing very little. For example: an application that opens a transaction, updates a row, then waits for a user to click OK before committing; a report running a long query at a strict isolation level; or a large batch update during the working day. Each has a different fix, from shorter transactions to row versioning to moving the batch to the evening.

System freezing for no obvious reason?

Tell us when it happens and which applications use the database. A few lines are enough.

Tell us what’s not working