| From: | Robert Treat <rob(at)xzilla(dot)net> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, Christophe Pettus <xof(at)thebuild(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, rmt(at)lists(dot)postgresql(dot)org |
| Subject: | Re: REPACK (CONCURRENTLY) doesn't handle invalid indexes |
| Date: | 2026-09-14 14:02:28 |
| Message-ID: | CABV9wwOfL+5YfCK8mKzgerQKFPuLPgHg8Arsqp0nDTzP6ug0Dg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs pgsql-hackers |
On Sun, Sep 13, 2026 at 10:35 PM shihao zhong <zhong950419(at)gmail(dot)com> wrote:
>
> Hi,
>
> The check in 0c5d6269614 tests indisready, so it does not catch an index
> that is ready but not valid. CREATE INDEX CONCURRENTLY leaves such an
> index when it fails during validation, and for a unique index that means
> the table contains duplicates.
>
>
> I reproduced it: 6M rows, CREATE UNIQUE INDEX CONCURRENTLY, and a
> duplicate inserted while the build was running. The index ends up with
> indisready = true, indisvalid = false. On master with 0c5d6269614:
>
> REPACK u -> succeeds after 17s, index stays invalid
> REPACK (CONCURRENTLY) u -> fails after 15s:
> ERROR: could not create unique index "u_c_uniq_repacknew"
>
> So the inconsistency the commit wanted to remove is still there for this
> case, and the concurrent form fails only after copying the table.
>
The patch looks right to me, and I think I am +1 for this generally,
though I would note that we are widening the scope here such that
indexes that could succeed with a rebuild would now cause an error, so
we're a little less functional though a little more behaviorally
consistent.
> The attached patch checks indisvalid instead. Both forms then fail
> immediately with the new error. It also adds the ready-but-invalid case
> to the test. A validation failure needs a concurrent session, so the
> test sets indisvalid = false in pg_index directly. If that is too hacky,
> I can drop that part.
>
This does feel hacky, since we're being manipulative rather than
testing a real scenario. I think what we want would be to follow the
lead of src/test/modules/injection_points/sql/reindex_conc.sql?
Robert Treat
https://xzilla.net
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2026-09-14 14:05:49 | Re: FOR PORTION OF code review |
| Previous Message | Greg Burd | 2026-09-14 14:01:15 | Re: Support for 8-byte TOAST values, round two |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Daniel Gustafsson | 2026-09-14 11:28:11 | Re: Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace |