public inbox for [email protected]  
help / color / mirror / Atom feed
From: Amit Kapila <[email protected]>
To: [email protected]
Subject: pgsql: Add a new slot sync worker to synchronize logical slots.
Date: Thu, 22 Feb 2024 10:07:34 +0000
Message-ID: <[email protected]> (raw)

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, Amit Kapila
Discussion: https://postgr.es/m/[email protected]

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(-)



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: Add a new slot sync worker to synchronize logical slots.
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox