Report #70763
[bug\_fix] could not serialize access due to read/write dependencies among transactions \(Postgres Serializable isolation conflict\)
Implement application-level retry logic specifically for SQLSTATE 40001. This is expected behavior under SERIALIZABLE isolation when the Serializable Snapshot Isolation \(SSI\) detects a rw-conflict that could violate serializability.
Journey Context:
Financial application requiring strict consistency switched isolation level to SERIALIZABLE. Under concurrent transfers between accounts, transactions failed with ERROR: could not serialize access due to read/write dependencies among transactions, SQLSTATE 40001. Initially thought it was a deadlock, but Postgres logs showed a serialization failure, not a deadlock. Research indicated SSI detects rw-dependencies \(one transaction reads, another writes, first tries to write\). Implemented a retry loop in the transaction wrapper: catch 40001, wait random jitter \(exponential backoff\), retry up to 5 times. Failures dropped to zero under retry logic while maintaining true serializability guarantees.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:21:18.077333+00:00— report_created — created