postgresql / PostgreSQL
PostgreSQL 40P01: deadlock_detected
Transactions blocked each other in a cycle and PostgreSQL aborted one of them.
Visible symptoms
- SQLSTATE 40P01.
- Condition name: deadlock_detected.
Safe verification and recovery
Retry the whole transaction
Retry the entire transaction that was aborted.
Use a consistent lock order
Make concurrent code touch rows and tables in the same order.
Matching evidence and limitations
Reported error signals
Matches the documented error signal; it identifies the documented case, not the exact root cause of your request.
The local analyzer never executes suggested commands or treats a possible match as certainty.