pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Detect and report update_deleted conflicts.
Date: Mon, 04 Aug 2025 04:23:24 +0000
Message-ID: <E1uimjM-000dvB-1H@gemulon.postgresql.org> (raw)

Detect and report update_deleted conflicts.

This enhancement builds upon the infrastructure introduced in commit
228c370868, which enables the preservation of deleted tuples and their
origin information on the subscriber. This capability is crucial for
handling concurrent transactions replicated from remote nodes.

The update introduces support for detecting update_deleted conflicts
during the application of update operations on the subscriber. When an
update operation fails to locate the target row-typically because it has
been concurrently deleted-we perform an additional table scan. This scan
uses the SnapshotAny mechanism and we do this additional scan only when
the retain_dead_tuples option is enabled for the relevant subscription.

The goal of this scan is to locate the most recently deleted tuple-matching
the old column values from the remote update-that has not yet been removed
by VACUUM and is still visible according to our slot (i.e., its deletion
is not older than conflict-detection-slot's xmin). If such a tuple is
found, the system reports an update_deleted conflict, including the origin
and transaction details responsible for the deletion.

This provides a groundwork for more robust and accurate conflict
resolution process, preventing unexpected behavior by correctly
identifying cases where a remote update clashes with a deletion from
another origin.

Author: Zhijie Hou <houzj.fnst@fujitsu.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/OS0PR01MB5716BE80DAEB0EE2A6A5D1F5949D2@OS0PR01MB5716.jpnprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/fd5a1a0c3e566f7fc860838084466a1c25944281

Modified Files
--------------
doc/src/sgml/catalogs.sgml                 |   3 +-
doc/src/sgml/logical-replication.sgml      |  16 ++
doc/src/sgml/monitoring.sgml               |  11 ++
doc/src/sgml/ref/create_subscription.sgml  |   9 +-
src/backend/catalog/system_views.sql       |   1 +
src/backend/executor/execReplication.c     | 251 ++++++++++++++++++++++++++++-
src/backend/replication/logical/conflict.c |  22 +++
src/backend/replication/logical/worker.c   | 186 ++++++++++++++++++---
src/backend/utils/adt/pgstatfuncs.c        |  14 +-
src/include/catalog/catversion.h           |   2 +-
src/include/catalog/pg_proc.dat            |   6 +-
src/include/executor/executor.h            |  14 +-
src/include/replication/conflict.h         |   3 +
src/include/replication/worker_internal.h  |   5 +-
src/test/regress/expected/rules.out        |   3 +-
src/test/subscription/t/035_conflicts.pl   |  66 +++++++-
16 files changed, 566 insertions(+), 46 deletions(-)



Message-ID: <E1uimjM-000dvB-1H@gemulon.postgresql.org>
Permalink:  ../E1uimjM-000dvB-1H@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uimjM-000dvB-1H@gemulon.postgresql.org

 · 

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: pgsql-committers@postgresql.org
  Cc: akapila@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Detect and report update_deleted conflicts.
  In-Reply-To: <E1uimjM-000dvB-1H@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