pgsql: pg_recvlogical: send final feedback on SIGINT/SIGTERM shutdown

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pg_recvlogical: send final feedback on SIGINT/SIGTERM shutdown
Date: 2026-07-08 03:20:07
Message-ID: E1whIpT-0005gn-0r@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pg_recvlogical: send final feedback on SIGINT/SIGTERM shutdown

Previously, when pg_recvlogical exited due to SIGINT or SIGTERM,
it could terminate without sending final feedback for the last decoded
changes it had already written locally. So, if pg_recvlogical was
restarted afterwards, the server-side logical replication slot could
still point behind those changes, causing them to be sent again.

Make pg_recvlogical send final feedback once more during SIGINT/SIGTERM
shutdown, before sending CopyDone. This gives the server one more chance
to advance the slot far enough to avoid resending already-written data,
so users are less likely to see duplicate decoded output after stopping
and restarting pg_recvlogical.

This remains a best-effort improvement rather than a guarantee. Depending
on when the signal arrives, pg_recvlogical can already have written
decoded output that the server cannot yet safely treat as confirmed, so a
later restart can still receive duplicate data.

Author: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAHGQGwE83z9O=X7ADMsSa3e1EuP3_GgqHjFt5SmPDNxZo_wgJA@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/bin/pg_basebackup/pg_recvlogical.c | 23 +++++++++
src/bin/pg_basebackup/t/030_pg_recvlogical.pl | 74 +++++++++++++++++++++++++++
2 files changed, 97 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-07-08 03:46:39 pgsql: doc: Clarify COPY FROM WHERE expression restrictions
Previous Message Richard Guo 2026-07-08 03:02:40 pgsql: Tighten nullingrels checks for outer joins