Обсуждение: pgsql: Add a new slot sync worker to synchronize logical slots.

Поиск
Список
Период
Сортировка

pgsql: Add a new slot sync worker to synchronize logical slots.

От
Amit Kapila
Дата:
Add a new slot sync worker to synchronize logical slots.

By enabling slot synchronization, all the failover logical replication
slots on the primary (assuming configurations are appropriate) are
automatically created on the physical standbys and are synced
periodically. The slot sync worker on the standby server pings the primary
server at regular intervals to get the necessary failover logical slots
information and create/update the slots locally. The slots that no longer
require synchronization are automatically dropped by the worker.

The nap time of the worker is tuned according to the activity on the
primary. The slot sync worker waits for some time before the next
synchronization, with the duration varying based on whether any slots were
updated during the last cycle.

A new parameter sync_replication_slots enables or disables this new
process.

On promotion, the slot sync worker is shut down by the startup process to
drop any temporary slots acquired by the slot sync worker and to prevent
the worker from trying to fetch the failover slots.

A functionality to allow logical walsenders to wait for the physical will
be done in a subsequent commit.

Author: Shveta Malik, Hou Zhijie based on design inputs by Masahiko Sawada and Amit Kapila
Reviewed-by: Masahiko Sawada, Bertrand Drouvot, Peter Smith, Dilip Kumar, Ajin Cherian, Nisha Moond, Kuroda Hayato,
AmitKapila 
Discussion: https://postgr.es/m/514f6f2f-6833-4539-39f1-96cd1e011f23@enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/93db6cbda037f1be9544932bd9a785dabf3ff712

Modified Files
--------------
doc/src/sgml/config.sgml                           |  18 +
doc/src/sgml/logicaldecoding.sgml                  |   5 +-
src/backend/access/transam/xlogrecovery.c          |  15 +
src/backend/postmaster/postmaster.c                |  93 ++-
.../libpqwalreceiver/libpqwalreceiver.c            |   3 +
src/backend/replication/logical/slotsync.c         | 702 +++++++++++++++++++--
src/backend/replication/slot.c                     |  14 +
src/backend/replication/slotfuncs.c                |   4 +-
src/backend/replication/walsender.c                |   2 +-
src/backend/storage/lmgr/proc.c                    |  13 +-
src/backend/utils/activity/pgstat_io.c             |   1 +
src/backend/utils/activity/wait_event_names.txt    |   2 +
src/backend/utils/init/miscinit.c                  |   9 +-
src/backend/utils/init/postinit.c                  |   8 +-
src/backend/utils/misc/guc_tables.c                |  10 +
src/backend/utils/misc/postgresql.conf.sample      |   1 +
src/include/miscadmin.h                            |   1 +
src/include/replication/slotsync.h                 |  21 +-
.../recovery/t/040_standby_failover_slots_sync.pl  | 120 ++++
19 files changed, 966 insertions(+), 76 deletions(-)