From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix assertion failure with REINDEX and event triggers
Date: Wed, 06 Dec 2023 23:31:20 +0000
Message-ID: <E1rB1MN-008wIn-M1@gemulon.postgresql.org> (raw)
Fix assertion failure with REINDEX and event triggers
A REINDEX CONCURRENTLY run on a table with no indexes would always pop
the topmost snapshot from the active snapshot stack, making the snapshot
handling inconsistent between the multiple-relation and single-relation
cases. This commit slightly changes the snapshot stack handling so as a
snapshot is popped only ReindexMultipleInternal() in this case after a
relation has been reindexed, fixing a problem where an event trigger
function may need a snapshot but does not have one. This also keeps the
places where PopActiveSnapshot() is called closer to each other.
While on it, this expands the existing tests to cover all the cases that
could be faced with REINDEX commands and such event triggers, for one or
more relations, with or without indexes.
This behavior is inconsistent since 5dc92b844e68, but we've never had a
need for an active snapshot at the end of a REINDEX until now.
Thanks also to Jian He for the input.
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/cb538743-484c-eb6a-a8c5-359980cd3a17@gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/c426f7c2b36a5efd9bcef2a2dfcc559f7879cd84
Modified Files
--------------
src/backend/commands/indexcmds.c | 5 ++-
src/test/regress/expected/event_trigger.out | 52 +++++++++++++++++++++++++++++
src/test/regress/sql/event_trigger.sql | 45 +++++++++++++++++++++++++
3 files changed, 99 insertions(+), 3 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: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix assertion failure with REINDEX and event triggers
In-Reply-To: <E1rB1MN-008wIn-M1@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