Postgres Errors Deadlocks

Use when transactions fail with deadlock detected, designing locking order, or building a queue with row locks. Prevents retrying only the failed statement instead of the whole transaction, inconsistent lock-acquisition order across code paths, and long transactions amplifying lock contention. Covers SQLSTATE 40P01 deadlock_detected, deadlock_timeout, the automatic victim-abort, log_lock_waits diagnosis, pg_locks + pg_blocking_pids inspection, consistent lock-ordering prevention, SELECT FOR UPDATE NOWAIT / SKIP LOCKED, whole-transaction retry pattern. Keywords: deadlock, deadlock detected, 40P01, deadlock_timeout, lock wait, SELECT FOR UPDATE, NOWAIT, SKIP LOCKED, pg_blocking_pids, log_lock_waits, retry transaction, deadlock detected error, transactions keep deadlocking, how to avoid deadlocks, lock ordering

Impertio-Studio 56c3797 4 files · 30.0 KB Updated

File contents

impertio-studio/postgresql-claude-skill-package/tree/main/skills/source/postgres-errors/postgres-errors-deadlocks commit 56c37977ff

Frequently asked questions

npx skillmds@latest add impertio-studio/postgres-errors-deadlocks