From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Log the conflicts while applying changes in logical replication.
Date: Tue, 20 Aug 2024 03:17:16 +0000
Message-ID: <E1sgFMy-000WvI-J6@gemulon.postgresql.org> (raw)
Log the conflicts while applying changes in logical replication.
This patch provides the additional logging information in the following
conflict scenarios while applying changes:
insert_exists: Inserting a row that violates a NOT DEFERRABLE unique constraint.
update_differ: Updating a row that was previously modified by another origin.
update_exists: The updated row value violates a NOT DEFERRABLE unique constraint.
update_missing: The tuple to be updated is missing.
delete_differ: Deleting a row that was previously modified by another origin.
delete_missing: The tuple to be deleted is missing.
For insert_exists and update_exists conflicts, the log can include the origin
and commit timestamp details of the conflicting key with track_commit_timestamp
enabled.
update_differ and delete_differ conflicts can only be detected when
track_commit_timestamp is enabled on the subscriber.
We do not offer additional logging for exclusion constraint violations because
these constraints can specify rules that are more complex than simple equality
checks. Resolving such conflicts won't be straightforward. This area can be
further enhanced if required.
Author: Hou Zhijie
Reviewed-by: Shveta Malik, Amit Kapila, Nisha Moond, Hayato Kuroda, Dilip Kumar
Discussion: https://postgr.es/m/OS0PR01MB5716352552DFADB8E9AD1D8994C92@OS0PR01MB5716.jpnprd01.prod.outlook.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/9758174e2e5cd278cf37e0980da76b51890e0011
Modified Files
--------------
doc/src/sgml/logical-replication.sgml | 103 +++++-
src/backend/access/index/genam.c | 5 +-
src/backend/catalog/index.c | 5 +-
src/backend/executor/execIndexing.c | 17 +-
src/backend/executor/execMain.c | 7 +-
src/backend/executor/execReplication.c | 236 ++++++++++----
src/backend/executor/nodeModifyTable.c | 5 +-
src/backend/replication/logical/Makefile | 1 +
src/backend/replication/logical/conflict.c | 488 ++++++++++++++++++++++++++++
src/backend/replication/logical/meson.build | 1 +
src/backend/replication/logical/worker.c | 115 +++++--
src/include/executor/executor.h | 5 +
src/include/replication/conflict.h | 58 ++++
src/test/subscription/t/001_rep_changes.pl | 18 +-
src/test/subscription/t/013_partition.pl | 53 +--
src/test/subscription/t/029_on_error.pl | 11 +-
src/test/subscription/t/030_origin.pl | 47 +++
src/tools/pgindent/typedefs.list | 1 +
18 files changed, 1033 insertions(+), 143 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: Log the conflicts while applying changes in logical replication.
In-Reply-To: <E1sgFMy-000WvI-J6@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