pgsql: reindexdb: Forbid index-level REINDEX with CONCURRENTLY and mult

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: reindexdb: Forbid index-level REINDEX with CONCURRENTLY and mult
Date: 2026-10-07 01:40:27
Message-ID: E1xEGdv-00000000cnm-45Ok@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

reindexdb: Forbid index-level REINDEX with CONCURRENTLY and multiple jobs

reindexdb batches the REINDEX commands of all indexes attached to the
same table into a single multi-statement query when using multiple jobs,
as two steps with query "gen" and "run".

Such a query fails with REINDEX CONCURRENTLY, as this command cannot run
inside a transaction block. Batching cannot be avoided because the
indexes of one table have to be re-indexed one at a time to avoid
conflicts across jobs.

Let's error out cleanly on the reindexdb side if this combination of
options is used, instead of having the server complain about that. This
case has not been considered by 47f99a407d.

If there is interest in supporting this combination of options, the code
should be redesigned for this purpose with some better batching, rather
than try to use sets of "gen" and "run" routines. As currently written,
an index-level reindexdb uses a set of "gen" steps with one final "run"
step, which is nice code-wise. (Note: I doubt that that this would be
worth the effort.)

Author: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Discussion: https://postgr.es/m/CALdSSPiEkAmS+n7Ea9XDMrLjkbQk=CrB7zw1kcq9B47hfKUhXw@mail.gmail.com
Backpatch-through: 17

Branch
------
REL_19_STABLE

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

Modified Files
--------------
src/bin/scripts/reindexdb.c | 3 +++
src/bin/scripts/t/090_reindexdb.pl | 10 ++++++++++
2 files changed, 13 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-10-07 01:40:28 pgsql: reindexdb: Forbid index-level REINDEX with CONCURRENTLY and mult
Previous Message Richard Guo 2026-10-07 01:30:29 Re: pgsql: Teach expr_is_nonnullable() to handle more expression types