Repository navigation
feat(schemadiff): name the index a REINDEX CONCURRENTLY copy belongs to - #734
Conversation
InvalidIndex.ReindexOf names the valid index on the same table that an invalid index is a REINDEX CONCURRENTLY copy of, matched on the server's copy names, including a name truncated to fit the suffix. It is empty for any other invalid index and when more than one valid index fits. Signed-off-by: Armand Parajon <armand@squareup.com>
…held reindex A held REINDEX CONCURRENTLY waits on every older transaction in the database, which a shared test server's other tests read as a lock wait on their own holder, so one cancelled its run early. A failed unique build under a copy's name leaves the same catalog state without waiting on anyone. Signed-off-by: Armand Parajon <armand@squareup.com>
|
🤖 Review findings - created by Kiran's code review agent - for pg-sprite/pull/734, 5fd562a. Verdict: 5 findings — 3 non-blocking (name-only match, running multi-index reindex, test coverage), 2 suggestions. Non-blocking1. A name-only match labels an index with a different definition as a reindex copy, and the test pins that as correct. The subquery checks only the table and the name ( 2. While a multi-index 3. The test never runs a real REINDEX, and the General suggestions4. A prefix match can cancel an exact match. When the copy's name is 60 bytes or longer, the 5. The subquery is the dense compound SQL that AGENTS.md asks to avoid. The suffix regex appears three times, inside a nested The one thing that could have broken, verifiedTruncation matching. The server's Verified correct
This review was generated by Claude Code (claude-opus-5-5). |
… its table reindexes ReindexOf now names an index only when it has the copy's definition, and an exact name wins over a truncated one. A REINDEX CONCURRENTLY of the copy's table counts as its builder, since the progress view names only the index it is on now. The test runs real failed reindexes for the truncated, numbered and multibyte names, and covers _ccold. Signed-off-by: Armand Parajon <armand@squareup.com>
|
🤖 Addressed every finding from the review of 5fd562a in f8d3608:
The catalog-qualification test (CO-9) and the schemadiff integration tests pass. — Claude Code (Claude Opus 5.5) |
Why
A REINDEX CONCURRENTLY that is cancelled or fails leaves its copy of the index invalid beside the index it rebuilt. The copy only duplicates a valid index, so dropping it is the whole fix. That advice is different from the advice for an abandoned build.
InvalidIndexdid not say which index a copy belongs to, so a caller had to match the server's copy names itself and read the catalog again to confirm the original exists.What
InvalidIndex.ReindexOfnames the valid index on the same table that an invalid index is a REINDEX CONCURRENTLY copy of._ccnewor_ccoldsuffix, a number when that name is taken, and the index's name truncated to fit. The listing matches the valid index whose name is the copy's name without the suffix. When the copy's name is at the identifier limit, it matches the valid index whose name starts with that.ReindexOfis empty for any other invalid index, for an index that only has a copy's suffix, and when more than one valid index fits.Before and after
orders_region_idxis valid. AREINDEX INDEX CONCURRENTLY orders_region_idxwas cancelled and leftorders_region_idx_ccnewinvalid.How
A correlated subquery in the existing listing finds the one valid index on the copy's table that the name rule matches. The listing never reads anything beyond its single catalog query, and every catalog name and operator stays
pg_catalog-qualified. The test leaves each copy invalid with a failed unique build under the copy's name. That is the same catalog state a cancelled reindex leaves, without holding a reindex that would wait on every older transaction in a shared test database. One copy carries the truncated name the server gives a copy of a 63-byte index name, checked against real cancelled reindexes. The test also lists a failed build whose name only looks like a copy's.Risk
The listing adds one field and changes no existing one. Only the name links a copy to its index, so an ambiguous match reports no index rather than a guess. Upholds CO-9: the new subquery qualifies every catalog name and operator.
Upgrade notes
None.
🤖 Generated with Claude Code