pgsql: Fix assertion failure with REINDEX and event triggers - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Fix assertion failure with REINDEX and event triggers
Date
Msg-id E1rB1MN-008wIn-M1@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Nathan Bossart
Date:
Subject: pgsql: Suppress -Wunused-result warning about write().
Next
From: Amit Kapila
Date:
Subject: pgsql: Fix issues in binary_upgrade_logical_slot_has_caught_up().