Skip to content

Commit 3a7369b

Browse files
mw5hyuzefovich
authored andcommitted
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 df7c75a commit 3a7369b

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
@@ -2925,7 +2925,12 @@ func indexBackfillInTxn(
29252925

29262926
var backfiller backfill.IndexBackfiller
29272927
if err := backfiller.InitForLocalUse(
2928-
ctx, evalCtx, semaCtx, tableDesc, indexBackfillerMon,
2928+
ctx,
2929+
evalCtx,
2930+
semaCtx,
2931+
tableDesc,
2932+
indexBackfillerMon,
2933+
evalCtx.Planner.ExecutorConfig().(*ExecutorConfig).VecIndexManager,
29292934
); err != nil {
29302935
return err
29312936
}

pkg/sql/backfill/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ go_library(
4646
"//pkg/sql/vecindex/vecencoding",
4747
"//pkg/util/admission/admissionpb",
4848
"//pkg/util/ctxgroup",
49+
"//pkg/util/errorutil/unimplemented",
4950
"//pkg/util/hlc",
5051
"//pkg/util/intsets",
5152
"//pkg/util/log",

pkg/sql/backfill/backfill.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/cockroachdb/cockroach/pkg/sql/vecindex"
4040
"github.com/cockroachdb/cockroach/pkg/sql/vecindex/cspann"
4141
"github.com/cockroachdb/cockroach/pkg/sql/vecindex/vecencoding"
42+
"github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented"
4243
"github.com/cockroachdb/cockroach/pkg/util/log"
4344
"github.com/cockroachdb/cockroach/pkg/util/mon"
4445
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
@@ -594,10 +595,12 @@ func (ib *IndexBackfiller) InitForLocalUse(
594595
semaCtx *tree.SemaContext,
595596
desc catalog.TableDescriptor,
596597
mon *mon.BytesMonitor,
598+
vecIndexManager *vecindex.Manager,
597599
) error {
598600

599601
// Initialize ib.added.
600-
if err := ib.initIndexes(ctx, evalCtx.Codec, desc, nil /* allowList */, 0 /*sourceIndex*/, nil); err != nil {
602+
// TODO(150163): Pass vecIndexManager once vector index build is supported with the legacy schema changer.
603+
if err := ib.initIndexes(ctx, evalCtx.Codec, desc, nil /* allowList */, 0 /*sourceIndex*/, nil /*vecIndexManager*/); err != nil {
601604
return err
602605
}
603606

@@ -879,6 +882,13 @@ func (ib *IndexBackfiller) initIndexes(
879882
continue
880883
}
881884

885+
if vecIndexManager == nil {
886+
return unimplemented.NewWithIssue(
887+
150163,
888+
"vector index build not supported with the legacy schema changer",
889+
)
890+
}
891+
882892
if ib.VectorIndexes == nil {
883893
ib.VectorIndexes = make(map[descpb.IndexID]VectorIndexHelper)
884894
}

pkg/sql/logictest/testdata/logic_test/vector_index

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,3 +688,25 @@ statement ok
688688
CREATE VECTOR INDEX vec_idx ON test_145973 (v)
689689

690690
subtest end
691+
692+
subtest test_backfill_149236
693+
694+
statement ok
695+
set autocommit_before_ddl=off;
696+
697+
statement ok
698+
BEGIN;
699+
700+
statement ok
701+
CREATE TABLE test_backfill_149236 (a INT PRIMARY KEY, b INT, vec1 VECTOR(3));
702+
703+
statement error pgcode 0A000 vector index build not supported with the legacy schema changer
704+
CREATE VECTOR INDEX idx ON test_backfill_149236 (vec1);
705+
706+
statement ok
707+
COMMIT;
708+
709+
statement ok
710+
SET autocommit_before_ddl=on;
711+
712+
subtest end

0 commit comments

Comments
 (0)