Intermediate LevelPostgreSQL
What is hot_standby_feedback and how does it prevent query cancellation on read replicas?
❓ Interview Prompt: Explain `hot_standby_feedback`, primary VACUUM tuple cleanup, replica query cancellation (`canceling statement due to conflict with recovery`), and replication lag.
When long-running queries run on a Read Replica, the Primary server might 'VACUUM' dead tuples that the replica query still needs to read, causing 'canceling statement due to conflict with recovery' errors!
The 'hot_standby_feedback' Fix:
Setting 'hot_standby_feedback = on' on the replica sends real-time feedback to the Primary server about active replica transaction XIDs, preventing the Primary from vacuuming tuples needed by replica queries!
Code Implementation Example
sql
-- On Read Replica postgresql.conf:
hot_standby_feedback = on💡Enabling hot_standby_feedback to prevent read replica query cancellations.
🎯 Interview Key Takeaway
Enable hot_standby_feedback = on on read replicas to prevent long-running queries from being canceled during primary VACUUM cleanups.
#hot_standby_feedback#Replication#Read Replica#Intermediate
Back to all PostgreSQL Questions→