postgresql/src/include/replication
Amit Kapila 5509055d69 Add sequence synchronization for logical replication.
This patch introduces sequence synchronization. Sequences that are synced
will have 2 states:
   - INIT (needs [re]synchronizing)
   - READY (is already synchronized)

A new sequencesync worker is launched as needed to synchronize sequences.
A single sequencesync worker is responsible for synchronizing all
sequences. It begins by retrieving the list of sequences that are flagged
for synchronization, i.e., those in the INIT state. These sequences are
then processed in batches, allowing multiple entries to be synchronized
within a single transaction. The worker fetches the current sequence
values and page LSNs from the remote publisher, updates the corresponding
sequences on the local subscriber, and finally marks each sequence as
READY upon successful synchronization.

Sequence synchronization occurs in 3 places:
1) CREATE SUBSCRIPTION
    - The command syntax remains unchanged.
    - The subscriber retrieves sequences associated with publications.
    - Published sequences are added to pg_subscription_rel with INIT
      state.
    - Initiate the sequencesync worker to synchronize all sequences.

2) ALTER SUBSCRIPTION ... REFRESH PUBLICATION
    - The command syntax remains unchanged.
    - Dropped published sequences are removed from pg_subscription_rel.
    - Newly published sequences are added to pg_subscription_rel with INIT
      state.
    - Initiate the sequencesync worker to synchronize only newly added
      sequences.

3) ALTER SUBSCRIPTION ... REFRESH SEQUENCES
    - A new command introduced for PG19 by f0b3573c3a.
    - All sequences in pg_subscription_rel are reset to INIT state.
    - Initiate the sequencesync worker to synchronize all sequences.
    - Unlike "ALTER SUBSCRIPTION ... REFRESH PUBLICATION" command,
      addition and removal of missing sequences will not be done in this
      case.

Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Hou Zhijie <houzj.fnst@fujitsu.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAA4eK1LC+KJiAkSrpE_NwvNdidw9F2os7GERUeSxSKv71gXysQ@mail.gmail.com
2025-11-05 05:59:58 +00:00
..
conflict.h Don't include execnodes.h in replication/conflict.h 2025-09-25 14:52:41 +02:00
decode.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
logical.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
logicallauncher.h Preserve conflict-relevant data during logical replication. 2025-07-23 02:56:00 +00:00
logicalproto.h Change publication's publish_generated_columns option type to enum. 2025-01-23 15:28:37 +05:30
logicalrelation.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
logicalworker.h Add sequence synchronization for logical replication. 2025-11-05 05:59:58 +00:00
message.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
origin.h Remove pg_replication_origin's TOAST table. 2025-05-07 14:47:36 -05:00
output_plugin.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
pgoutput.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
reorderbuffer.h Add mem_exceeded_count column to pg_stat_replication_slots. 2025-10-08 10:05:04 -07:00
slot.h Make invalid primary_slot_name follow standard GUC error reporting. 2025-10-22 20:09:43 +09:00
slotsync.h pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
snapbuild.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
snapbuild_internal.h pg_logicalinspect: Fix possible crash when passing a directory path. 2025-03-11 09:56:40 -07:00
syncrep.h Allow redeclaration of typedef yyscan_t 2025-09-12 08:16:00 +02:00
walreceiver.h Add WalRcvGetState() to retrieve the state of a WAL receiver 2025-11-04 12:57:36 +09:00
walsender.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
walsender_private.h Allow redeclaration of typedef yyscan_t 2025-09-12 08:16:00 +02:00
worker_internal.h Add sequence synchronization for logical replication. 2025-11-05 05:59:58 +00:00