| From: | shihao zhong <zhong950419(at)gmail(dot)com> |
|---|---|
| To: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
| Cc: | 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 02:35:00 |
| Message-ID: | CAGRkXqRA4YetT8Nu3+1-45+ffTwi2bd1d1eDFME39Y9OPRMytQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs pgsql-hackers |
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 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.
Thanks,
Shihao
| Attachment | Content-Type | Size |
|---|---|---|
| 0002-Make-REPACK-reject-invalid-indexes-not-only-indisrea.patch | application/octet-stream | 5.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shihao zhong | 2026-09-14 02:46:00 | Re: [Patch] New pg_stat_tablespace view |
| Previous Message | Chao Li | 2026-09-14 02:22:10 | Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Álvaro Herrera | 2026-09-13 12:27:13 | Re: REPACK (CONCURRENTLY) doesn't handle invalid indexes |