Report #72366
[bug\_fix] Postgres deadlock detected
Ensure all transactions acquire locks on resources in a consistent global order \(e.g., always lock table A before table B\), or implement retry logic for deadlock exceptions. Root cause: Concurrent transactions lock rows/tables in different orders creating a circular wait \(A holds lock 1 waits for 2, B holds 2 waits for 1\).
Journey Context:
E-commerce checkout spiking to 500 errors under load with Postgres logs showing deadlock detected. Process 12345: UPDATE inventory SET count=count-1 WHERE id=1; Process 12346: UPDATE orders SET status='confirmed' WHERE id=2; then 12345 tried to update orders and 12346 tried to update inventory. Circular dependency. Refactored all code paths to always update inventory tables before orders tables, eliminating the circular wait condition. Deadlocks ceased.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T04:03:02.888665+00:00— report_created — created