pgsql: Add WALRCV_CONNECTING state to the WAL receiver

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add WALRCV_CONNECTING state to the WAL receiver
Date: 2026-01-23 05:28:16
Message-ID: E1vj9iR-0027Wj-32@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add WALRCV_CONNECTING state to the WAL receiver

Previously, a WAL receiver freshly started would set its state to
WALRCV_STREAMING immediately at startup, before actually establishing a
replication connection.

This commit introduces a new state called WALRCV_CONNECTING, which is
the state used when the WAL receiver freshly starts, or when a restart
is requested, with a switch to WALRCV_STREAMING once the connection to
the upstream server has been established with COPY_BOTH, meaning that
the WAL receiver is ready to stream changes. This change is useful for
monitoring purposes, especially in environments with a high latency
where a connection could take some time to be established, giving some
room between the [re]start phase and the streaming activity.

From the point of view of the startup process, that flips the shared
memory state of the WAL receiver when it needs to be stopped, the
existing WALRCV_STREAMING and the new WALRCV_CONNECTING states have the
same semantics: the WAL receiver has started and it can be stopped.

Based on an initial suggestion from Noah Misch, with some input from me
about the design.

Author: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: Rahila Syed <rahilasyed90(at)gmail(dot)com>
Discussion: https://postgr.es/m/CABPTF7VQ5tGOSG5TS-Cg+Fb8gLCGFzxJ_eX4qg+WZ3ZPt=FtwQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a36164e7465fd1e10e94569e9c1c07656e38a9de

Modified Files
--------------
doc/src/sgml/monitoring.sgml | 6 ++++++
src/backend/replication/walreceiver.c | 21 ++++++++++++++++++---
src/backend/replication/walreceiverfuncs.c | 3 ++-
src/include/replication/walreceiver.h | 1 +
4 files changed, 27 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2026-01-23 16:47:55 pgsql: Fix some rounding code for shared memory.
Previous Message Amit Langote 2026-01-23 01:24:21 pgsql: Fix bogus ctid requirement for dummy-root partitioned targets