SQLSTATE 40001 ERROR Class 40: Transaction Rollback

serialization_failure could not serialize access due to read/write dependencies — 40001

PostgreSQL error “could not serialize access due to read/write dependencies — 40001” (SQLSTATE 40001): what it means, common causes, and how to fix it.

PG 9.1, 10, 11, 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

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

  1. Retry the transaction — this error is expected and retryable.
  2. Keep SERIALIZABLE transactions short to reduce conflicts.
  3. Use explicit locking or a lower isolation level if appropriate for the workload.

Related & next steps

Reference: PostgreSQL 18 Section 13.2 “Transaction Isolation”.

Was this helpful?