THE COLLECTION

Library

Everything you’ve found. Nothing you need to save twice.

1 articles
Browse at your own pace.
01
incident.ioUNREAD

Debugging deadlocks in Postgres

Argues that Postgres deadlocks (SQLSTATE 40P01) usually reflect inconsistent lock ordering in transaction design, best fixed by restructuring operations into a consistent order. Case study: two seemingly identical bulk upserts deadlocked because rows were randomly ordered (a Go map converted to a slice) and Postgres acquires locks row-by-row during inserts; sorting rows solved it. Alternatives like explicit locks (FOR UPDATE, advisory locks) or jittered retries trade off parallelism and raise lock timeout risk.