pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix updates of indisvalid for partitioned indexes
Date: Fri, 14 Jul 2023 01:14:11 +0000
Message-ID: <E1qK7Nr-000FaV-B3@gemulon.postgresql.org> (raw)

Fix updates of indisvalid for partitioned indexes

indisvalid is switched to true for partitioned indexes when all its
partitions have valid indexes when attaching a new partition, up to the
top-most parent if all its leaves are themselves valid when dealing with
multiple layers of partitions.

The copy of the tuple from pg_index used to switch indisvalid to true
came from the relation cache, which is incorrect.  Particularly, in the
case reported by Shruthi Gowda, executing a series of commands in a
single transaction would cause the validation of partitioned indexes to
use an incorrect version of a pg_index tuple, as indexes are reloaded
after an invalidation request with RelationReloadIndexInfo(), a much
faster version than a full index cache rebuild.  In this case, the
limited information updated in the cache leads to an incorrect version
of the tuple used.  One of the symptoms reported was the following
error, with a replica identity update, for instance:
"ERROR: attempted to update invisible tuple"

This is incorrect since 8b08f7d, so backpatch all the way down.

Reported-by: Shruthi Gowda
Author: Michael Paquier
Reviewed-by: Shruthi Gowda, Dilip Kumar
Discussion: https://postgr.es/m/CAASxf_PBcxax0wW-3gErUyftZ0XrCs3Lrpuhq4-Z3Fak1DoW7Q@mail.gmail.com
Backpatch-through: 11

Branch
------
REL_11_STABLE

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

Modified Files
--------------
src/backend/commands/tablecmds.c       | 15 +++++---
src/test/regress/expected/indexing.out | 63 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/indexing.sql      | 43 +++++++++++++++++++++++
3 files changed, 117 insertions(+), 4 deletions(-)



view thread (7+ messages)

Message-ID: <E1qK7Nr-000FaV-B3@gemulon.postgresql.org>
Permalink:  ../E1qK7Nr-000FaV-B3@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qK7Nr-000FaV-B3@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: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix updates of indisvalid for partitioned indexes
  In-Reply-To: <E1qK7Nr-000FaV-B3@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