A distributed serialization anomaly occurs when concurrent operations appear inconsistently ordered across database nodes, violating transaction isolation. It commonly arises when a long-running read uses a standby while the primary changes and vacuums the same data. section 5.6
A report fails on standby beta
A report on standby beta calculates a sum and average while users delete rows on primary alpha. After alpha vacuums those rows, beta cancels the report with `canceling statement due to conflict with recovery`: the query still needs row versions that recovery must remove. section 5.6
SELECT sum(balance) FROM test.accounts UNION SELECT avg(balance) FROM test.accounts; ERROR: canceling statement due to conflict with recovery DETAIL: User query might have needed to see row versions that must be removed.
Use the PostgreSQL error output to recognize recovery conflicts caused by a standby query requiring removed row versions. section 5.6
Treat the anomaly as a consistency-versus-latency decision:
- Enforce synchronous replication when extreme correctness outweighs performance; network round trips can bottleneck database latency. section 5.6
- Accept stale or out-of-date reads when low latency matters and the workload tolerates weaker consistency. section 5.6
- Avoid spreading one application-side transaction across multiple nodes unless strong consistency and isolation are provided; multi-master systems require particular caution. section 5.6 section 5.7
