]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Add retry logic to pg_sync_replication_slots(). master github/master
authorAmit Kapila <akapila@postgresql.org>
Mon, 15 Dec 2025 02:50:21 +0000 (02:50 +0000)
committerAmit Kapila <akapila@postgresql.org>
Mon, 15 Dec 2025 02:50:21 +0000 (02:50 +0000)
commit0d2d4a0ec3eca64e7f5ce7f7630b56a561b2663c
tree5f877b010ea54ca7f71102fc7964521b213f123e
parent33980eaa6df0b1358ba2e70edbe9efd56dbd7fa6
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@gmail.com>
Author: Hou Zhijie <houzj.fnst@fujitsu.com>
Reviewed-by: Shveta Malik <shveta.malik@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Yilin Zhang <jiezhilove@126.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CAFPTHDZAA%2BgWDntpa5ucqKKba41%3DtXmoXqN3q4rpjO9cdxgQrw%40mail.gmail.com
doc/src/sgml/func/func-admin.sgml
doc/src/sgml/logicaldecoding.sgml
src/backend/replication/logical/slotsync.c
src/backend/utils/activity/wait_event_names.txt
src/test/recovery/t/040_standby_failover_slots_sync.pl