release-26.2: sql/backfill: fix CREATE VECTOR INDEX panic with virtual computed columns#169250
Merged
trunk-io[bot] merged 1 commit intoApr 28, 2026
Merged
Conversation
…umns VectorIndexHelper.vectorOrd was set to vectorCol.Ordinal(), the column's position in desc.AllColumns(). The backfiller's rowVals slice, however, is sized by the filtered set of columns produced by makeIndexBackfillColumns: public columns that aren't stored in the source primary index and aren't referenced by any added index get dropped. When such a column (e.g. an unreferenced virtual computed column) sits at an ordinal before the vector column, the vector column's table-wide ordinal points past the end of rowVals and BuildIndexEntriesChunk panics with "index out of range". Resolve the rowVals index from ib.colIdxMap, which maps ColumnID to position in ib.cols. Compute it once in IndexBackfiller.init(), after both initIndexes (which builds the helpers) and initCols (which builds colIdxMap) have run, and store it on the helper. Rename the field to rowValsIdx so the index space is unambiguous. init() now returns an error so the impossible-but-asserted "vector column missing from backfill column set" case can be reported instead of crashing. Resolves: #169059 Epic: none Release note (bug fix): Fixed a panic during CREATE VECTOR INDEX backfill when the table contained a public column ordered before the vector column that was not stored in the source primary index and was not referenced by the new index. In practice this was triggered by virtual computed columns. The schema change crashed the SQL node processing the backfill instead of completing. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
cf5f9c6 to
ce73222
Compare
Author
|
Thanks for opening a backport. Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate. |
Contributor
|
😎 Merged successfully - details. |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport 1/1 commits from #169060 on behalf of @mw5h.
VectorIndexHelper.vectorOrdwas set tovectorCol.Ordinal(), thecolumn's position in
desc.AllColumns(). The backfiller'srowValsslice, however, is sized by the filtered set of columns produced by
makeIndexBackfillColumns: public columns that aren't stored in thesource primary index and aren't referenced by any added index get
dropped. When such a column (e.g. an unreferenced virtual computed
column) sits at an ordinal before the vector column, the vector
column's table-wide ordinal points past the end of
rowValsandBuildIndexEntriesChunkpanics withindex out of range.Resolve the
rowValsindex fromib.colIdxMap, which mapsColumnIDto position in
ib.cols. Compute it once inIndexBackfiller.init(),after both
initIndexes(which builds the helpers) andinitCols(which builds
colIdxMap) have run, and store it on the helper. Renamethe field to
rowValsIdxso the index space is unambiguous.init()now returns an error so the impossible-but-asserted "vector column
missing from backfill column set" case can be reported instead of
crashing.
Resolves: #169059
Epic: none
Release note (bug fix): Fixed a panic during CREATE VECTOR INDEX
backfill when the table contained a public column ordered before the
vector column that was not stored in the source primary index and was
not referenced by the new index. In practice this was triggered by
virtual computed columns. The schema change crashed the SQL node
processing the backfill instead of completing.
Release justification: Low risk fix to a reproducible panic.