Report #85295
[bug\_fix] FATAL: terminating connection due to conflict with recovery
On the standby replica, set hot\_standby\_feedback = on in postgresql.conf \(sends feedback to primary to delay vacuum\); alternatively, increase max\_standby\_streaming\_delay or max\_standby\_archive\_delay to allow queries to wait longer before being canceled; or redirect long-running queries to the primary. Root cause: A long-running query on the hot standby holds a snapshot or locks that conflict with WAL replay \(e.g., vacuum removing tuples the query still needs\), forcing Postgres to cancel the query to maintain replication consistency.
Journey Context:
A data science team runs heavy Tableau reports against a PostgreSQL hot standby replica. Every morning, long-running queries fail with FATAL: terminating connection due to conflict with recovery. The DBA initially increases max\_standby\_streaming\_delay from 30s to 10 minutes, but the error persists for the longest queries. They examine the primary's logs and see vacuum processes removing dead tuples. The team realizes the standby queries are holding back vacuum on the primary because hot\_standby\_feedback is off. After enabling hot\_standby\_feedback on the standby, the primary delays vacuuming the specific rows the standby needs, allowing the reports to complete without cancellation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:45:17.556506+00:00— report_created — created