From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow altering of two_phase option of a SUBSCRIPTION.
Date: Wed, 24 Jul 2024 04:54:40 +0000
Message-ID: <E1sWU1Q-000wWl-Rr@gemulon.postgresql.org> (raw)
Allow altering of two_phase option of a SUBSCRIPTION.
The two_phase option is controlled by both the publisher (as a slot
option) and the subscriber (as a subscription option), so the slot option
must also be modified.
Changing the 'two_phase' option for a subscription from 'true' to 'false'
is permitted only when there are no pending prepared transactions
corresponding to that subscription. Otherwise, the changes of already
prepared transactions can be replicated again along with their corresponding
commit leading to duplicate data or errors.
To avoid data loss, the 'two_phase' option for a subscription can only be
changed from 'false' to 'true' once the initial data synchronization is
completed. Therefore this is performed later by the logical replication worker.
Author: Hayato Kuroda, Ajin Cherian, Amit Kapila
Reviewed-by: Peter Smith, Hou Zhijie, Amit Kapila, Vitaly Davydov, Vignesh C
Discussion: https://postgr.es/m/8fab8-65d74c80-1-2f28e880@39088166
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/1462aad2e4474ab61174f8ab00992cd3d6d57c7b
Modified Files
--------------
doc/src/sgml/protocol.sgml | 18 ++-
doc/src/sgml/ref/alter_subscription.sgml | 36 ++++-
src/backend/access/transam/twophase.c | 79 ++++++++++
src/backend/commands/subscriptioncmds.c | 169 ++++++++++++++++-----
.../libpqwalreceiver/libpqwalreceiver.c | 22 ++-
src/backend/replication/logical/launcher.c | 10 +-
src/backend/replication/logical/worker.c | 25 +--
src/backend/replication/slot.c | 45 ++++--
src/backend/replication/walsender.c | 32 ++--
src/bin/psql/tab-complete.c | 2 +-
src/include/access/twophase.h | 5 +
src/include/replication/slot.h | 3 +-
src/include/replication/walreceiver.h | 12 +-
src/include/replication/worker_internal.h | 3 +-
src/test/regress/expected/subscription.out | 5 +-
src/test/regress/sql/subscription.sql | 5 +-
src/test/subscription/t/021_twophase.pl | 95 +++++++++++-
17 files changed, 452 insertions(+), 114 deletions(-)
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: pgsql-committers@postgresql.org
Cc: akapila@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Allow altering of two_phase option of a SUBSCRIPTION.
In-Reply-To: <E1sWU1Q-000wWl-Rr@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox