| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY |
| Date: | 2026-11-20 04:47:01 |
| Message-ID: | E1xUGWb-00000000TEB-033J@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Pin relations in phase 1 of REINDEX CONCURRENTLY
Phase 1 of ReindexRelationConcurrently() evaluates index expressions and
predicates when computing the safety of each index and when creating the
definition of each new index. These may call functions run as the table
owner.
The old and new indexes processed in the previous iterations of the loop
were closed at this stage. Hence, a function was able to drop one of
them or reindex one of the new indexes, leading to an assertion failure
in the build phase, or to an internal error with a dropped index
committed.
The relations opened in phase 1 are now kept opened until the session
locks are taken, so as DDLs on them are blocked by CheckTableNotInUse().
The build and validation phases already pin the relations, and the
protections in build phase limit the damage to an ERROR.
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Reviewed-by: Shihao Zhong <zhong950419(at)gmail(dot)com>
Discussion: https://postgr.es/m/aver6A1EQEd2FaKq@paquier.xyz
Backpatch-through: 15
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/d94964f14f39936d69c6b8d3fc5020f0fdae1617
Modified Files
--------------
src/backend/commands/indexcmds.c | 28 ++++++++++++++++++----
src/test/regress/expected/create_index.out | 37 +++++++++++++++++++++++++++++-
src/test/regress/sql/create_index.sql | 26 ++++++++++++++++++++-
3 files changed, 84 insertions(+), 7 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-11-20 04:47:02 | pgsql: Pin relations in phase 1 of REINDEX CONCURRENTLY |
| Previous Message | Peter Geoghegan | 2026-11-19 22:53:59 | pgsql: Fix auto_explain index scan NULL pointer dereference. |