Skip to content

Investigate lock waits

Find blockers, queued DDL predecessors and the transaction owner.

Find the chain

Use lock --tree first to see the full dependency hierarchy before narrowing to one PID or table. A queued DDL request can delay later queries before it holds its requested lock, and a direct blocker is not always the root holder.

kbdiag lock --tree
kbdiag lock <pid>
kbdiag lock --table public.orders
kbdiag session <pid>
kbdiag txn

Snapshots can change between commands. --table and <pid> filter displayed chains while [GLOBAL FINDINGS] still evaluates all collected lock rows; blocker edge resolution itself is capped globally at 50 waiting PIDs. Cross-database lock OIDs are not resolved against tables in other databases.

Inspect the owner

session <pid> displays full SQL (or [LAST SQL] when idle in transaction), waits, held/requested locks, and transaction age. idle in transaction shows an open transaction, not proof that it blocks anyone. Check txn for aged open transactions or prepared 2PC transactions that can hold locks after their session closes.

Verify before acting

Without monitoring privileges (sys_monitor), SQL for other users is masked; where wait-start timestamps are unavailable (such as versions relying on state_change), wait durations can also be hidden and yield UNKNOWN (while V9 sys_locks.waitstart may still expose wait duration even with SQL redacted). Coordinate with the application or transaction owner before committing, rolling back, or cancelling a backend; kbdiag never executes session termination.

Lock evidence and rules · Session evidence · Transaction horizons