Skip to content

release-26.2: sql/backfill: fix CREATE VECTOR INDEX panic with virtual computed columns#169250

Merged
trunk-io[bot] merged 1 commit into
release-26.2from
blathers/backport-release-26.2-169060
Apr 28, 2026
Merged

release-26.2: sql/backfill: fix CREATE VECTOR INDEX panic with virtual computed columns#169250
trunk-io[bot] merged 1 commit into
release-26.2from
blathers/backport-release-26.2-169060

Conversation

@blathers-crl
Copy link
Copy Markdown

@blathers-crl blathers-crl Bot commented Apr 28, 2026

Backport 1/1 commits from #169060 on behalf of @mw5h.


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.


Release justification: Low risk fix to a reproducible panic.

…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>
@blathers-crl blathers-crl Bot force-pushed the blathers/backport-release-26.2-169060 branch from cf5f9c6 to ce73222 Compare April 28, 2026 16:31
@blathers-crl blathers-crl Bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Apr 28, 2026
@blathers-crl
Copy link
Copy Markdown
Author

blathers-crl Bot commented Apr 28, 2026

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.

@blathers-crl blathers-crl Bot requested review from DrewKimball, mw5h and spilchen April 28, 2026 16:31
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented Apr 28, 2026

😎 Merged successfully - details.

@blathers-crl blathers-crl Bot added backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team labels Apr 28, 2026
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@spilchen spilchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@trunk-io trunk-io Bot merged commit 15ac948 into release-26.2 Apr 28, 2026
23 checks passed
@trunk-io trunk-io Bot deleted the blathers/backport-release-26.2-169060 branch April 28, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. T-sql-queries SQL Queries Team target-release-26.2.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants