Lock waits
Lock is the most directly actionable class: a backend asked the lock manager for a heavyweight lock and an incompatible holder has not released it. Unlike LWLocks, these waits usually have rows in pg_locks and a useful result from pg_blocking_pids().
Read the blocking graph, not the victim count
Twenty waiters can all be symptoms of one idle transaction. Start at the head of the graph, then decide whether the holder is doing useful work, abandoned, or participating in an expected DDL/deploy window.
- Normal: sub-second lock handoff during ordinary writes or planned DDL.
- Watch: any user-facing waiter persists beyond its latency objective, or at least 10% of active sessions wait on the same root blocker.
- Urgent: the root holder is
idle in transaction, the chain keeps growing, critical DDL blocks traffic, or deadlocks begin to rise.
Events to recognize
| Event | Usually means |
|---|---|
| relation | Table/index-level lock conflict, often DDL versus DML |
| transactionid | Waiting for another transaction’s outcome, commonly row updates |
| tuple | Competing tuple locks or a long row-lock queue |
| extend | Sessions serialize while extending one relation |
| virtualxid | DDL waits for transactions that might still use an object |
| advisory | Application-defined advisory-lock coordination |
Blocker query
Common misreads
- A session listed as a blocker is not automatically safe to terminate; it may be the only writer preserving an invariant.
transactioniddoes not mean transaction-ID exhaustion.relationdoes not identify the relation by itself; joinpg_locks.relationtopg_class.- Increasing
lock_timeoutchanges how long victims wait; it does not remove the blocker.
Waiting to acquire an advisory user lock
Waiting to acquire a lock on a remote transaction being applied by a logical replication subscriber
Waiting to extend a relation
Waiting to update pg_database.datfrozenxid and pg_database.datminmxid
Waiting to acquire a lock on a non-relation database object
Waiting to acquire a lock on a page of a relation
Waiting to acquire a lock on a relation
Waiting to acquire a speculative insertion lock
Waiting for a transaction to finish
Waiting to acquire a lock on a tuple
Waiting to acquire a user lock
Waiting to acquire a virtual transaction ID lock