Deadlock Analysis

Turn a database deadlock error into a code change. Collect the engine's own report, not the application stack trace: PostgreSQL's log entry naming both statements, or MySQL's LATEST DETECTED DEADLOCK section. Lay the two transactions out as a lock-order grid, classify the cycle (opposite-order batch updates, foreign-key parent locks, gap and next-key locks, unique-index insert races, an unindexed UPDATE), then fix in order: one canonical lock order, a shorter transaction, a narrowing index, READ COMMITTED where semantics allow. A bounded jittered retry on 40P01 or 1213 is the safety net, not the fix. Use for "deadlock detected", "Deadlock found when trying to get lock", "error 1213 keeps happening", "40P01 spikes after the release". Not for a stall with no cycle (lock-queue-triage), wrong results (transaction-race-hunt), a retried batch deadlock (db-migration).

greenblacked Updated
The twenty-nine plugins: coding, family, gamedev, operations, delivery, security, manager, personal, career, design, llm, data, techdocs, assurance, client-apps

File contents

greenblacked/AI commit 55ecb1b5a4

Frequently asked questions

npx get-skill add greenblacked/deadlock-analysis