pgsql: Improve handling of dropped relations for REINDEX DATABASE/SCHEM - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Improve handling of dropped relations for REINDEX DATABASE/SCHEM
Date
Msg-id E1kDGLM-0002ke-K3@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Improve handling of dropped relations for REINDEX DATABASE/SCHEMA/SYSTEM

When multiple relations are reindexed, a scan of pg_class is done first
to build the list of relations to work on.  However the REINDEX logic
has never checked if a relation listed still exists when beginning the
work on it, causing for example sudden cache lookup failures.

This commit adds safeguards against dropped relations for REINDEX,
similarly to VACUUM or CLUSTER where we try to open the relation,
ignoring it if it is missing.  A new option is added to the REINDEX
routines to control if a missed relation is OK to ignore or not.

An isolation test, based on REINDEX SCHEMA, is added for the concurrent
and non-concurrent cases.

Author: Michael Paquier
Reviewed-by: Anastasia Lubennikova
Discussion: https://postgr.es/m/20200813043805.GE11663@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1d65416661bbb0b165865a521ce038ffb61b12ad

Modified Files
--------------
src/backend/access/table/table.c               | 34 ++++++++++++++
src/backend/catalog/index.c                    | 34 ++++++++++++--
src/backend/commands/indexcmds.c               | 63 ++++++++++++++++++++++++--
src/include/access/table.h                     |  1 +
src/include/nodes/parsenodes.h                 |  1 +
src/test/isolation/expected/reindex-schema.out | 17 +++++++
src/test/isolation/isolation_schedule          |  1 +
src/test/isolation/specs/reindex-schema.spec   | 32 +++++++++++++
8 files changed, 174 insertions(+), 9 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Improve test coverage of ginvacuum.c.
Next
From: Alvaro Herrera
Date:
Subject: pgsql: Fix typo in comment