Introduce a new GUC 'standby_slot_names'.
authorAmit Kapila <akapila@postgresql.org>
Fri, 8 Mar 2024 02:40:45 +0000 (08:10 +0530)
committerAmit Kapila <akapila@postgresql.org>
Fri, 8 Mar 2024 02:40:45 +0000 (08:10 +0530)
commitbf279ddd1c28ce0251446ee90043a4cb96e5db0f
tree642eb01435995795793fc61cedcc66949c824f1d
parent453c46873774219243501b8efc16b2b5a5e9d194
Introduce a new GUC 'standby_slot_names'.

This patch provides a way to ensure that physical standbys that are
potential failover candidates have received and flushed changes before
the primary server making them visible to subscribers. Doing so guarantees
that the promoted standby server is not lagging behind the subscribers
when a failover is necessary.

The logical walsender now guarantees that all local changes are sent and
flushed to the standby servers corresponding to the replication slots
specified in 'standby_slot_names' before sending those changes to the
subscriber.

Additionally, the SQL functions pg_logical_slot_get_changes,
pg_logical_slot_peek_changes and pg_replication_slot_advance are modified
to ensure that they process changes for failover slots only after physical
slots specified in 'standby_slot_names' have confirmed WAL receipt for those.

Author: Hou Zhijie and Shveta Malik
Reviewed-by: Masahiko Sawada, Peter Smith, Bertrand Drouvot, Ajin Cherian, Nisha Moond, Amit Kapila
Discussion: https://postgr.es/m/514f6f2f-6833-4539-39f1-96cd1e011f23@enterprisedb.com
18 files changed:
doc/src/sgml/config.sgml
doc/src/sgml/func.sgml
doc/src/sgml/logicaldecoding.sgml
src/backend/replication/logical/logicalfuncs.c
src/backend/replication/logical/slotsync.c
src/backend/replication/slot.c
src/backend/replication/slotfuncs.c
src/backend/replication/walsender.c
src/backend/utils/activity/wait_event_names.txt
src/backend/utils/misc/guc_tables.c
src/backend/utils/misc/postgresql.conf.sample
src/include/replication/slot.h
src/include/replication/walsender.h
src/include/replication/walsender_private.h
src/include/utils/guc_hooks.h
src/test/recovery/t/006_logical_decoding.pl
src/test/recovery/t/040_standby_failover_slots_sync.pl
src/tools/pgindent/typedefs.list