Skip to content

Commit 5cc9de0

Browse files
committed
sql: disable vector index backfill in the legacy schema changer
Through an oversight, the legacy schema changer never received a copy of the vector manager, required for backfilling vector indexes. In practice, we always use the declarative schema changer for creating vector indexes, so this wasn't caught in QA. Sentry caught the oversight. Completely fixing this problem is more complicated than what we have time to do in 25.3, so for now the plan is to disable backfilling vector indices with the legacy schema changer, which should be a corner case to begin with. Informs: #149236 Release note (bug fix): Attempting to create a vector index with the legacy schema changer will now fail gracefully instead of crashing the node.
1 parent d3b81e1 commit 5cc9de0

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

pkg/sql/backfill.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2917,7 +2917,12 @@ func indexBackfillInTxn(
29172917

29182918
var backfiller backfill.IndexBackfiller
29192919
if err := backfiller.InitForLocalUse(
2920-
ctx, evalCtx, semaCtx, tableDesc, indexBackfillerMon,
2920+
ctx,
2921+
evalCtx,
2922+
semaCtx,
2923+
tableDesc,
2924+
indexBackfillerMon,
2925+
evalCtx.Planner.ExecutorConfig().(*ExecutorConfig).VecIndexManager,
29212926
); err != nil {
29222927
return err
29232928
}

pkg/sql/backfill/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ go_library(
4949
"//pkg/sql/vecindex/vecstore/vecstorepb",
5050
"//pkg/util/admission/admissionpb",
5151
"//pkg/util/ctxgroup",
52+
"//pkg/util/errorutil/unimplemented",
5253
"//pkg/util/hlc",
5354
"//pkg/util/intsets",
5455
"//pkg/util/log",

pkg/sql/backfill/backfill.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/cockroachdb/cockroach/pkg/sql/vecindex/vecencoding"
4141
"github.com/cockroachdb/cockroach/pkg/sql/vecindex/vecstore"
4242
"github.com/cockroachdb/cockroach/pkg/sql/vecindex/vecstore/vecstorepb"
43+
"github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented"
4344
"github.com/cockroachdb/cockroach/pkg/util/log"
4445
"github.com/cockroachdb/cockroach/pkg/util/mon"
4546
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
@@ -605,6 +606,7 @@ func (ib *IndexBackfiller) InitForLocalUse(
605606
semaCtx *tree.SemaContext,
606607
desc catalog.TableDescriptor,
607608
mon *mon.BytesMonitor,
609+
vecIndexManager *vecindex.Manager,
608610
) (retErr error) {
609611
if mon == nil {
610612
return errors.AssertionFailedf("memory monitor must be provided")
@@ -616,7 +618,8 @@ func (ib *IndexBackfiller) InitForLocalUse(
616618
}()
617619

618620
// Initialize ib.added.
619-
if err := ib.initIndexes(ctx, evalCtx, desc, nil /* allowList */, 0 /*sourceIndex*/, nil); err != nil {
621+
// TODO(150163): Pass vecIndexManager once vector index build is supported with the legacy schema changer.
622+
if err := ib.initIndexes(ctx, evalCtx, desc, nil /* allowList */, 0 /*sourceIndex*/, nil /*vecIndexManager*/); err != nil {
620623
return err
621624
}
622625

@@ -921,6 +924,13 @@ func (ib *IndexBackfiller) initIndexes(
921924
continue
922925
}
923926

927+
if vecIndexManager == nil {
928+
return unimplemented.NewWithIssue(
929+
150163,
930+
"vector index build not supported with the legacy schema changer",
931+
)
932+
}
933+
924934
if ib.VectorIndexes == nil {
925935
ib.VectorIndexes = make(map[descpb.IndexID]VectorIndexHelper)
926936
}

pkg/sql/logictest/testdata/logic_test/vector_index

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,3 +1141,25 @@ statement ok
11411141
DROP TABLE composite_pk
11421142

11431143
subtest end
1144+
1145+
subtest test_backfill_149236
1146+
1147+
statement ok
1148+
set autocommit_before_ddl=off;
1149+
1150+
statement ok
1151+
BEGIN;
1152+
1153+
statement ok
1154+
CREATE TABLE test_backfill_149236 (a INT PRIMARY KEY, b INT, vec1 VECTOR(3));
1155+
1156+
statement error pgcode 0A000 vector index build not supported with the legacy schema changer
1157+
CREATE VECTOR INDEX idx ON test_backfill_149236 (vec1);
1158+
1159+
statement ok
1160+
COMMIT;
1161+
1162+
statement ok
1163+
SET autocommit_before_ddl=on;
1164+
1165+
subtest end

0 commit comments

Comments
 (0)