pgsql: Add retry logic to pg_sync_replication_slots().

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add retry logic to pg_sync_replication_slots().
Date: 2025-12-15 02:59:05
Message-ID: E1vUyng-000pns-29@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add retry logic to pg_sync_replication_slots().

Previously, pg_sync_replication_slots() would finish without synchronizing
slots that didn't meet requirements, rather than failing outright. This
could leave some failover slots unsynchronized if required catalog rows or
WAL segments were missing or at risk of removal, while the standby
continued removing needed data.

To address this, the function now waits for the primary slot to advance to
a position where all required data is available on the standby before
completing synchronization. It retries cyclically until all failover slots
that existed on the primary at the start of the call are synchronized.
Slots created after the function begins are not included. If the standby
is promoted during this wait, the function exits gracefully and the
temporary slots will be removed.

Author: Ajin Cherian <itsajin(at)gmail(dot)com>
Author: Hou Zhijie <houzj(dot)fnst(at)fujitsu(dot)com>
Reviewed-by: Shveta Malik <shveta(dot)malik(at)gmail(dot)com>
Reviewed-by: Japin Li <japinli(at)hotmail(dot)com>
Reviewed-by: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Reviewed-by: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Yilin Zhang <jiezhilove(at)126(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAFPTHDZAA%2BgWDntpa5ucqKKba41%3DtXmoXqN3q4rpjO9cdxgQrw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0d2d4a0ec3eca64e7f5ce7f7630b56a561b2663c

Modified Files
--------------
doc/src/sgml/func/func-admin.sgml | 4 +-
doc/src/sgml/logicaldecoding.sgml | 16 +-
src/backend/replication/logical/slotsync.c | 226 +++++++++++++++++----
src/backend/utils/activity/wait_event_names.txt | 2 +-
.../recovery/t/040_standby_failover_slots_sync.pl | 57 ++++--
5 files changed, 245 insertions(+), 60 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2025-12-15 04:17:49 pgsql: Fix typo in tablecmds.c
Previous Message Michael Paquier 2025-12-15 01:37:23 pgsql: test_custom_stats: Fix compilation warning