public inbox for [email protected]
help / color / mirror / Atom feedFrom: Amit Kapila <[email protected]>
To: [email protected]
Subject: pgsql: Detect and Log multiple_unique_conflicts type conflict.
Date: Mon, 24 Mar 2025 07:17:11 +0000
Message-ID: <[email protected]> (raw)
Detect and Log multiple_unique_conflicts type conflict.
Introduce a new conflict type, multiple_unique_conflicts, to handle cases
where an incoming row during logical replication violates multiple UNIQUE
constraints.
Previously, the apply worker detected and reported only the first
encountered key conflict (insert_exists/update_exists), causing repeated
failures as each constraint violation needs to be handled one by one
making the process slow and error-prone.
With this patch, the apply worker checks all unique constraints upfront
once the first key conflict is detected and reports
multiple_unique_conflicts if multiple violations exist. This allows users
to resolve all conflicts at once by deleting all conflicting tuples rather
than dealing with them individually or skipping the transaction.
In the future, this will also allow us to specify different resolution
handlers for such a conflict type.
Add the stats for this conflict type in pg_stat_subscription_stats.
Author: Nisha Moond <[email protected]>
Author: Zhijie Hou <[email protected]>
Reviewed-by: Amit Kapila <[email protected]>
Reviewed-by: Peter Smith <[email protected]>
Reviewed-by: Dilip Kumar <[email protected]>
Discussion: https://postgr.es/m/CABdArM7FW-_dnthGkg2s0fy1HhUB8C3ELA0gZX1kkbs1ZZoV3Q@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/73eba5004a06a744b6b8570e42432b9e9f75997b
Modified Files
--------------
doc/src/sgml/logical-replication.sgml | 31 +++++++-
doc/src/sgml/monitoring.sgml | 12 +++
src/backend/catalog/system_views.sql | 1 +
src/backend/executor/execReplication.c | 30 +++++---
src/backend/replication/logical/conflict.c | 64 +++++++++-------
src/backend/replication/logical/worker.c | 68 ++++++++---------
src/backend/utils/adt/pgstatfuncs.c | 6 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 6 +-
src/include/replication/conflict.h | 26 +++++--
src/test/regress/expected/rules.out | 3 +-
src/test/subscription/meson.build | 1 +
src/test/subscription/t/035_conflicts.pl | 113 +++++++++++++++++++++++++++++
src/tools/pgindent/typedefs.list | 1 +
14 files changed, 276 insertions(+), 88 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: Detect and Log multiple_unique_conflicts type conflict.
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