pgsql: Avoid sending duplicate WAL locations in standby status replies

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid sending duplicate WAL locations in standby status replies
Date: 2026-03-26 11:55:23
Message-ID: E1w5jJ4-001XJZ-20@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid sending duplicate WAL locations in standby status replies

Previously, when the startup process applied WAL and requested walreceiver
to send an apply notification to the primary, walreceiver sent a status reply
unconditionally, even if the WAL locations had not advanced since
the previous update.

As a result, the standby could send two consecutive status reply messages
with identical WAL locations even though wal_receiver_status_interval had
not yet elapsed. This could unexpectedly reset the reported replication lag,
making it difficult for users to monitor lag. The second message was also
unnecessary because it reported no progress.

This commit updates walreceiver to send a reply only when the apply location
has advanced since the last status update, even when the startup process
requests a notification.

Author: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAOzEurTzcUrEzrH97DD7+Yz=HGPU81kzWQonKZvqBwYhx2G9_A@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/400a790a48eb7a1e76f23f9f6d8a6f7159395f65

Modified Files
--------------
src/backend/access/transam/xlogrecovery.c | 4 +-
src/backend/replication/walreceiver.c | 74 ++++++++++++++++++-------------
src/include/replication/walreceiver.h | 6 +--
3 files changed, 49 insertions(+), 35 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2026-03-26 14:06:03 pgsql: Fix -Wcast-qual warning
Previous Message Fujii Masao 2026-03-26 11:53:46 pgsql: Fix premature NULL lag reporting in pg_stat_replication