Posts about concurrency
Articles, guides and engineering notes about concurrency from the Relyt One team.
3 articles

Postgres "deadlock detected": how to read the error, reproduce it, and fix the four patterns behind it
What ERROR: deadlock detected (SQLSTATE 40P01) means in PostgreSQL, how to read the DETAIL and CONTEXT lines, and how to fix the four common deadlock patterns: rows updated in opposite order, unique keys inserted in opposite order, FOR SHARE followed by UPDATE, and SELECT FOR UPDATE on a parent row after inserting children. Every example reproduced with two sessions on Postgres 17.11.

Postgres transaction isolation levels in practice: the bugs Read Committed lets through
Read Committed, Repeatable Read and Serializable in PostgreSQL, reproduced with two psql sessions: lost updates, write skew, phantoms and the 'could not serialize access' errors (SQLSTATE 40001). Includes the fix for each bug, a retry function, and how to set the isolation level behind a transaction-mode connection pool. Tested on Postgres 17.11.

Postgres as a job queue: FOR UPDATE SKIP LOCKED, done right
How to build a background job queue in PostgreSQL 17 with SELECT ... FOR UPDATE SKIP LOCKED: why the naive SELECT-then-UPDATE claims the same job twice, why FOR UPDATE alone makes workers wait, leases and retries, LISTEN/NOTIFY, vacuum, and what polling workers do to a serverless compute. Every statement reproduced on Postgres 17.11.