Re: REPACK (CONCURRENTLY) doesn't handle invalid indexes

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: REPACK (CONCURRENTLY) doesn't handle invalid indexes
Date: 2026-07-27 21:20:52
Message-ID: CAN4CZFMdc--zwTpeNvZEUa1Ae04boM7np4H4=+Z7X=JsO2DLUQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> Wouldn't it make more sense to just ignore invalid indexes and not build
> anything at all for them?

I followed what REPACK/VACUUM FULL does - it similarly rebuilds
invalid indexes, shouldn't we keep the two consistent?

And by skipping you mean that we should create an empty index instead
when repack sees an invalid index?

One argument for that is that the current code only handles unique
constraint violation, while there's a preexisting issue that these
commands all fail with other index failures, except REINDEX TABLE
CONCURRENTLY, e.g.:

CREATE TABLE t (i int PRIMARY KEY, j int);
INSERT INTO t VALUES (1, 0), (2, 1);
CREATE INDEX CONCURRENTLY t_expr ON t ((1/j));

VACUUM FULL t;
CLUSTER t USING t_pkey;
REINDEX TABLE t;
ALTER TABLE t ALTER COLUMN j TYPE bigint;
REINDEX TABLE CONCURRENTLY t; -- only this works

If we would skip all invalid indexes, that could solve this too
(except for the ALTER TABLE).

I wanted to raise this issue separately, as this seems to be
preexisting in earlier versions, not a new bug. (and a more complex
discussion than "repack and repack (concurrently) should behave
similarly")

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Masahiko Sawada 2026-07-27 21:28:04 Re: BUG #19556: Segmentation fault in test_decoding
Previous Message Zsolt Parragi 2026-07-27 20:50:16 Re: Race between datachecksum enablement and create table with the file_copy strategy