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: Fix tuple search during apply after concurrent index DDL.
Date: Mon, 28 Sep 2026 11:24:01 +0000
Message-ID: <E1xB9Sj-00000001aym-1rW3@gemulon.postgresql.org> (raw)

Fix tuple search during apply after concurrent index DDL.

When searching the local relation by index, the apply worker can use the
first match only if the index is the relation's replica identity or
primary key. Otherwise, every match must be compared with the search slot.

Only the index OID was saved in the relation map, so this was determined
again during the search. Concurrent DROP INDEX or REINDEX can change the
index status between these two checks, causing the tuple search to fail
and the change to be silently skipped as an update_missing conflict.

Fix this by recording the answer as idxisreplident in the relation map
entry and avoid getting it second time in FindReplTupleInLocalRel() and
RelationFindReplTupleByIndex().

Oversight in 89e46da5e5.

Author: Mikhail Nikalayeu <mihailnikalayeu@gmail.com>
Author: vignesh C <vignesh21@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Zhijie Hou <houzj.fnst@fujitsu.com>
Discussion: https://postgr.es/m/CADzfLwUJovFcnknCC9wjZKECX9xecgnGzC2r2TMV8h4QDD_jwQ@mail.gmail.com
Backpatch-through: 16, where it was introduced

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2389f898eea60b445191b1bcaafada29781ab9dc

Modified Files
--------------
src/backend/executor/execReplication.c     | 37 ++++++++++---
src/backend/replication/logical/relation.c | 18 +++++--
src/backend/replication/logical/worker.c   | 83 +++++++++++++++++-------------
src/include/executor/executor.h            |  5 ++
src/include/replication/logicalrelation.h  |  4 ++
5 files changed, 98 insertions(+), 49 deletions(-)



view thread (5+ messages)

Message-ID: <E1xB9Sj-00000001aym-1rW3@gemulon.postgresql.org>
Permalink:  ../E1xB9Sj-00000001aym-1rW3@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xB9Sj-00000001aym-1rW3@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: akapila@postgresql.org
  Subject: Re: pgsql: Fix tuple search during apply after concurrent index DDL.
  In-Reply-To: <E1xB9Sj-00000001aym-1rW3@gemulon.postgresql.org>
  References: <E1xB9Sj-00000001aym-1rW3@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