One outer statement-budget rectangle contains work, lock-wait, work and wait blocks; separate red brackets under the waits show a timer for each acquisition.

Locks wait politely when a transaction grabs them

A lock wait can be healthy coordination or an expensive queue. PostgreSQL’s lock_timeout lets an operation stop waiting, but it does not diagnose why the holder is slow or decide whether retrying is appropriate. Choose the timeout from the operation’s latency budget, and inspect the blocking transaction before increasing the limit or multiplying attempts. ...

February 16, 2028 · 5 min · XB Field Notes
After a resource has observed epoch two, a token-two request reaches it while token one is stopped by the resource-side guard.

A fencing token guards against a stale leader

A lease can expire while its holder is paused, yet the old process can resume and send a delayed write. The storage service needs a way to reject superseded ownership. A fencing token supplies an ordered ownership epoch that travels with each mutation. Its protection depends on the resource checking the token, not merely on a lock service issuing one. ...

November 30, 2027 · 5 min · XB Field Notes
Session ownership steps from two acquisitions to one and then zero through two unlocks; rollback leaves both acquisitions held.

Advisory lock lifetime belongs to its connection or transaction

An advisory lock lets an application coordinate work using an identifier that need not correspond to a table row. For example, workers can agree that only one connection may refresh a particular report at a time. PostgreSQL manages ownership and contention, while the application defines what the identifier means and which work requires it. ...

November 24, 2027 · 4 min · XB Field Notes
Transaction A holds row 1 and needs row 2, while B holds row 2 and needs row 1. Directed waits form a cycle. PostgreSQL may reject either transaction with 40P01.

Deadlocks happen when two writers wait on each other

A deadlock requires a cycle of incompatible waits. If one transaction holds a row while another waits, the holder can still finish and release it. If both hold a resource the other needs, neither can complete that path. PostgreSQL detects the cycle and aborts one transaction, allowing the other to continue. The application must distinguish that rejection from an ordinary slow wait. ...

August 11, 2026 · 4 min · XB Field Notes