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 <[email protected]>
Discussion: 
https://postgr.es/m/CALdSSPiEkAmS+n7Ea9XDMrLjkbQk=crb7zw1kcq9b47hfku...@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(+)

Reply via email to