Fix reindexdb with parallel index-level conrurrent run - Mailing list pgsql-hackers

From Kirill Reshke
Subject Fix reindexdb with parallel index-level conrurrent run
Date
Msg-id CALdSSPiEkAmS+n7Ea9XDMrLjkbQk=CrB7zw1kcq9B47hfKUhXw@mail.gmail.com
Whole thread
List 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@pg-bench-dc:~/pgmaster$
/home/reshke/pgmaster/pgbinm/bin/reindexdb -p 7777 --concurrently -i
z_1 -i z_2 -j 1
reshke@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

pgsql-hackers by date:

Previous
From: ahmed
Date:
Subject: Re: Use instr_time for pg_stat_database block read/write time counters
Next
From: Alexandre Felipe
Date:
Subject: Re: BUG #19686: Rolling back SET TABLESPACE