pgsql: Add ALTER SUBSCRIPTION ... SKIP.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add ALTER SUBSCRIPTION ... SKIP.
Date: 2022-03-22 01:56:03
Message-ID: E1nWTkh-000ncF-2O@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Add ALTER SUBSCRIPTION ... SKIP.

This feature allows skipping the transaction on subscriber nodes.

If incoming change violates any constraint, logical replication stops
until it's resolved. Currently, users need to either manually resolve the
conflict by updating a subscriber-side database or by using function
pg_replication_origin_advance() to skip the conflicting transaction. This
commit introduces a simpler way to skip the conflicting transactions.

The user can specify LSN by ALTER SUBSCRIPTION ... SKIP (lsn = XXX),
which allows the apply worker to skip the transaction finished at
specified LSN. The apply worker skips all data modification changes within
the transaction.

Author: Masahiko Sawada
Reviewed-by: Takamichi Osumi, Hou Zhijie, Peter Eisentraut, Amit Kapila, Shi Yu, Vignesh C, Greg Nancarrow, Haiying Tang, Euler Taveira
Discussion: https://postgr.es/m/CAD21AoDeScrsHhLyEPYqN3sydg6PxAPVBboK=30xJfUVihNZDA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/208c5d65bbd60e33e272964578cb74182ac726a8

Modified Files
--------------
doc/src/sgml/catalogs.sgml | 10 +
doc/src/sgml/logical-replication.sgml | 27 +--
doc/src/sgml/ref/alter_subscription.sgml | 42 +++++
src/backend/catalog/pg_subscription.c | 1 +
src/backend/catalog/system_views.sql | 2 +-
src/backend/commands/subscriptioncmds.c | 73 ++++++++
src/backend/parser/gram.y | 9 +
src/backend/replication/logical/worker.c | 233 +++++++++++++++++++++++-
src/bin/pg_dump/pg_dump.c | 4 +
src/bin/psql/describe.c | 8 +-
src/bin/psql/tab-complete.c | 5 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_subscription.h | 5 +
src/include/nodes/parsenodes.h | 3 +-
src/test/regress/expected/subscription.out | 126 +++++++------
src/test/regress/sql/subscription.sql | 11 ++
src/test/subscription/t/029_disable_on_error.pl | 94 ----------
src/test/subscription/t/029_on_error.pl | 183 +++++++++++++++++++
18 files changed, 665 insertions(+), 173 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2022-03-22 02:06:46 Re: pgsql: Add ALTER SUBSCRIPTION ... SKIP.
Previous Message Andres Freund 2022-03-21 23:38:49 pgsql: pgstat: reorder pgstat.[ch] contents.

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-03-22 02:00:37 Re: Frontend error logging style
Previous Message wangw.fnst@fujitsu.com 2022-03-22 01:55:32 RE: Logical replication timeout problem