QA
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→

More PostgreSQL Interview Questions

Beginner LevelPostgreSQL

How to use pgvector in PostgreSQL for vector similarity search with HNSW indexes?

Beginner LevelPostgreSQL

What is PostgreSQL architecture and how do client backends connect via process fork model?

Beginner LevelPostgreSQL

What special built-in data types exist in PostgreSQL (JSONB, UUID, ARRAY, INET, TEXT)?