Diagnostic Queries
Symptoms
A SERIALIZABLE transaction was aborted because of read/write dependencies with other concurrent transactions that could violate serializability. PostgreSQL raises SQLSTATE 40001 (serialization_failure).
- Serializable Snapshot Isolation detected an unsafe dependency cycle.
- Common under SERIALIZABLE isolation with concurrency.
- The transaction should be retried.
What the server log shows
ERROR: could not serialize access due to read/write dependencies among transactions
DETAIL: Reason code: Canceled on identification as a pivot.
HINT: The transaction might succeed if retried.
Why PostgreSQL raises this — what the manual says
Section 13.2.3 Serializable Isolation Level:
“Applications using this level must be prepared to retry transactions due to serialization failures.”
Serializable Snapshot Isolation tracks read/write dependencies between concurrent transactions. When it finds a pattern (a “pivot”) that could yield a result inconsistent with some serial order, it aborts a transaction with 40001 to preserve serializability.
Common causes
- Concurrent SERIALIZABLE transactions with conflicting read/write sets.
- Hotspots where many transactions read and write overlapping data.
- Higher concurrency increasing dependency cycles.
How to fix it
- Retry the transaction — this error is expected and retryable.
- Keep SERIALIZABLE transactions short to reduce conflicts.
- Use explicit locking or a lower isolation level if appropriate for the workload.
Related & next steps
Reference: PostgreSQL 18 Section 13.2 “Transaction Isolation”.
Thanks — noted. This helps keep the database accurate.