Fix reindexdb with parallel index-level conrurrent run

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Fix reindexdb with parallel index-level conrurrent run
Date: 2026-10-02 17:03:39
Message-ID: CALdSSPiEkAmS+n7Ea9XDMrLjkbQk=CrB7zw1kcq9B47hfKUhXw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!
$subj doesn't work. I bumped into it while doing some corruption fixing.

repro:

create table z(i int);
create index z_1 on z(i);
create index z_2 on z(i);

reshke(at)pg-bench-dc:~/pgmaster$
/home/reshke/pgmaster/pgbinm/bin/reindexdb -p 7777 --concurrently -i
z_1 -i z_2 -j 1
reshke(at)pg-bench-dc:~/pgmaster$
/home/reshke/pgmaster/pgbinm/bin/reindexdb -p 7777 --concurrently -i
z_1 -i z_2 -j 2
reindexdb: error: processing of database "reshke" failed: ERROR:
REINDEX CONCURRENTLY cannot run inside a transaction block

The root cause is that reindexdb tries to parallelize REINDEX by
batching all commands related to one table in one job. However,
implementation of this makes multiple DDL query an multistatement
which is transformed into implicit transaction server-side.

Oversight of 47f99a407d. I didn't find any related bug report, so it
looks like this feature is not widely used. affected versions and
17-19 and master.

PFA fix.

--
Best regards,
Kirill Reshke

Attachment Content-Type Size
fix-bug29-0001-reindexdb-jobs-sametable-concurrently.patch application/octet-stream 5.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexandre Felipe 2026-10-02 17:06:39 Re: BUG #19686: Rolling back SET TABLESPACE
Previous Message ahmed 2026-10-02 17:03:24 Re: Use instr_time for pg_stat_database block read/write time counters