This is the multi-page printable view of this section. .
Lock waits
- 1: Lock: advisory
- 2: Lock: applytransaction
- 3: Lock: extend
- 4: Lock: frozenid
- 5: Lock: object
- 6: Lock: page
- 7: Lock: relation
- 8: Lock: spectoken
- 9: Lock: transactionid
- 10: Lock: tuple
- 11: Lock: userlock
- 12: Lock: virtualxid
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.
1 - Lock: advisory
advisory
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting to acquire an advisory user lock
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:428. The instrumented operation is: Waiting to acquire an advisory user lock. The lock manager could not grant the advisory heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:428 —
advisory - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:39 —
advisory
Related controls and signals
2 - Lock: applytransaction
applytransaction
VersionsPG 16-18
Evidence3 source location(s)
Official description
Waiting to acquire a lock on a remote transaction being applied by a logical replication subscriber
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| — | — | — | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:429. The instrumented operation is: Waiting to acquire a lock on a remote transaction being applied by a logical replication subscriber. The lock manager could not grant the applytransaction heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:429 —
applytransaction - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:40 —
applytransaction
Related controls and signals
3 - Lock: extend
extend
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting to extend a relation
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:419. The instrumented operation is: Waiting to extend a relation. The lock manager could not grant the extend heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:419 —
extend - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:30 —
extend
Related controls and signals
4 - Lock: frozenid
frozenid
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting to update pg_database.datfrozenxid and pg_database.datminmxid
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:420. The instrumented operation is: Waiting to update pg_database.datfrozenxid and pg_database.datminmxid. The lock manager could not grant the frozenid heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:420 —
frozenid - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:31 —
frozenid
Related controls and signals
5 - Lock: object
object
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting to acquire a lock on a non-relation database object
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:426. The instrumented operation is: Waiting to acquire a lock on a non-relation database object. The lock manager could not grant the object heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:426 —
object - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:37 —
object
Related controls and signals
6 - Lock: page
page
VersionsPG 13-18
Evidence2 source location(s)
Official description
Waiting to acquire a lock on a page of a relation
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:421. The instrumented operation is: Waiting to acquire a lock on a page of a relation. The lock manager could not grant the page heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:421 —
page
Related controls and signals
7 - Lock: relation
relation
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting to acquire a lock on a relation
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:418. The instrumented operation is: Waiting to acquire a lock on a relation. The lock manager could not grant the relation heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:418 —
relation - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:29 —
relation
Related controls and signals
8 - Lock: spectoken
spectoken
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting to acquire a speculative insertion lock
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:425. The instrumented operation is: Waiting to acquire a speculative insertion lock. The lock manager could not grant the spectoken heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:425 —
spectoken - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:36 —
spectoken
Related controls and signals
9 - Lock: transactionid
transactionid
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting for a transaction to finish
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:423. The instrumented operation is: Waiting for a transaction to finish. The lock manager could not grant the transactionid heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:423 —
transactionid - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:34 —
transactionid
Related controls and signals
10 - Lock: tuple
tuple
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting to acquire a lock on a tuple
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:422. The instrumented operation is: Waiting to acquire a lock on a tuple. The lock manager could not grant the tuple heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:422 —
tuple - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:33 —
tuple
Related controls and signals
11 - Lock: userlock
userlock
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting to acquire a user lock
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:427. The instrumented operation is: Waiting to acquire a user lock. The lock manager could not grant the userlock heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:427 —
userlock - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:38 —
userlock
Related controls and signals
12 - Lock: virtualxid
virtualxid
VersionsPG 13-18
Evidence3 source location(s)
Official description
Waiting to acquire a virtual transaction ID lock
| PG 13 | PG 14 | PG 15 | PG 16 | PG 17 | PG 18 |
|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Trigger mechanism
PG_WAIT_LOCK at src/backend/storage/lmgr/proc.c:1487 is the grep-verified reporting path. The public identity/resource is mapped at src/backend/utils/activity/wait_event_names.txt:424. The instrumented operation is: Waiting to acquire a virtual transaction ID lock. The lock manager could not grant the virtualxid heavyweight lock immediately. ProcSleep reports the lock wait and parks the backend on the lock’s wait queue until owners release or the request is cancelled.
Normal or trouble?
- Normal: Sub-second handoff during ordinary writes or planned DDL can be normal.
- Investigate: Investigate once a user-facing wait breaches its latency objective, a blocking chain grows, or the root holder is idle in transaction.
Diagnostic SQL
Response
- Build the pg_blocking_pids graph to its root.
- Inspect the root holder’s state, transaction age, and business purpose.
- Choose cancellation, timeout, or workload sequencing only after identifying the safest root action.
Source evidence
- PostgreSQL 18.6 · src/backend/storage/lmgr/proc.c:1487 —
PG_WAIT_LOCK - PostgreSQL 18.6 · src/backend/utils/activity/wait_event_names.txt:424 —
virtualxid - PostgreSQL 18.6 · src/backend/utils/adt/lockfuncs.c:35 —
virtualxid