pgsql: reindexdb: Fix the index-level REINDEX with multiple jobs

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: reindexdb: Fix the index-level REINDEX with multiple jobs
Date: 2025-03-16 11:34:27
Message-ID: E1ttmGB-002kVG-3C@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

reindexdb: Fix the index-level REINDEX with multiple jobs

47f99a407d introduced a parallel index-level REINDEX. The code was written
assuming that running run_reindex_command() with 'async == true' can schedule
a number of queries for a connection. That's not true, and the second query
sent using run_reindex_command() will wait for the completion of the previous
one.

This commit fixes that by putting REINDEX commands for the same table into a
single query.

Also, this commit removes the 'async' argument from run_reindex_command(),
as only its call always passes 'async == true'.

Reported-by: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Discussion: https://postgr.es/m/202503071820.j25zn3lo4hvn%40alvherre.pgsql
Reviewed-by: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/09ef2f8df1cd746d711ffd916bdd2e9526c51b65

Modified Files
--------------
src/bin/scripts/reindexdb.c | 135 ++++++++++++++++++++++++--------------------
1 file changed, 73 insertions(+), 62 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2025-03-16 11:34:37 pgsql: reindexdb: Fix the index-level REINDEX with multiple jobs
Previous Message Michael Paquier 2025-03-16 10:32:42 pgsql: pg_createsubscriber: Remove some code bloat in the atexit() call