From 84c56e99b0a4456b86ee09eeb1875662048289f9 Mon Sep 17 00:00:00 2001 From: Vaibhav Dalvi Date: Fri, 20 Nov 2026 11:24:02 +0000 Subject: [PATCH v3] walreceiver: Do not leave stale xmin on primary when status interval is zero When hot_standby_feedback is on and wal_receiver_status_interval is zero, walreceiver sends one feedback message at connect or on reload, and that message carries a valid xmin. After that nothing is sent, so the primary keeps this xmin forever and vacuum is held back. Fix by sending InvalidTransactionId when the interval is zero, so primary releases the xmin. The condition is kept in one helper, HotStandbyFeedbackEnabled(), used in all three places. Zero now means feedback is disabled. This is what the code already assumed since v16, and the docs now say it. Before v16, zero sent feedback on every call, but that was only a side effect. One consequence: a logical slot on the standby is not protected by the stale catalog_xmin anymore, so it can be invalidated when the interval is zero. This is documented and covered in the test. Not covered here: if Hot Standby is not active yet at connect time, an old xmin on the slot is not released. This is a separate problem, marked with an XXX comment. Add a TAP test for the xmin release on reload and on connect, and for catalog_xmin with a logical slot on the standby. Author: Vaibhav Dalvi Reviewed-by: Joao Rito Discussion: https://www.postgresql.org/message-id/flat/CA+vB=AHvkSsYXNNiVKakQtOEdyQBv7kob=LGESOdOC7AC0M9Ow@mail.gmail.com --- doc/src/sgml/config.sgml | 11 +- src/backend/replication/walreceiver.c | 28 +++- src/test/recovery/meson.build | 1 + ...62_hot_standby_feedback_status_interval.pl | 143 ++++++++++++++++++ 4 files changed, 177 insertions(+), 6 deletions(-) create mode 100644 src/test/recovery/t/062_hot_standby_feedback_status_interval.pl diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 341872823b3..7769dc687ca 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -4962,6 +4962,8 @@ ANY num_sync ( is effectively disabled too. There are additional cases where updates are sent while ignoring this parameter; for example, when processing of the existing WAL completes or when synchronous_commit is set to @@ -4989,10 +4991,17 @@ ANY num_sync (