Skip to content

Commit d548952

Browse files
ignore ongoing backfill vindex from routing selection (#13505)
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
1 parent df479ad commit d548952

6 files changed

Lines changed: 541 additions & 200 deletions

File tree

go/vt/vtgate/planbuilder/operators/sharded_routing.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ func newShardedRouting(vtable *vindexes.Table, id semantics.TableSet) Routing {
7979

8080
}
8181
for _, columnVindex := range vtable.ColumnVindexes {
82+
// ignore any backfilling vindexes from vindex selection.
83+
if columnVindex.IsBackfilling() {
84+
continue
85+
}
8286
routing.VindexPreds = append(routing.VindexPreds, &VindexPlusPredicates{ColVindex: columnVindex, TableID: id})
8387
}
8488
return routing

go/vt/vtgate/planbuilder/plan_test.go

Lines changed: 0 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -52,199 +52,6 @@ import (
5252
"vitess.io/vitess/go/vt/vtgate/vindexes"
5353
)
5454

55-
// hashIndex is a functional, unique Vindex.
56-
type hashIndex struct{ name string }
57-
58-
func (v *hashIndex) String() string { return v.name }
59-
60-
func (*hashIndex) Cost() int { return 1 }
61-
62-
func (*hashIndex) IsUnique() bool { return true }
63-
64-
func (*hashIndex) NeedsVCursor() bool { return false }
65-
66-
func (*hashIndex) Verify(context.Context, vindexes.VCursor, []sqltypes.Value, [][]byte) ([]bool, error) {
67-
return []bool{}, nil
68-
}
69-
70-
func (*hashIndex) Map(ctx context.Context, vcursor vindexes.VCursor, ids []sqltypes.Value) ([]key.Destination, error) {
71-
return nil, nil
72-
}
73-
74-
func newHashIndex(name string, _ map[string]string) (vindexes.Vindex, error) {
75-
return &hashIndex{name: name}, nil
76-
}
77-
78-
// lookupIndex is a unique Vindex, and satisfies Lookup.
79-
type lookupIndex struct{ name string }
80-
81-
func (v *lookupIndex) String() string { return v.name }
82-
83-
func (*lookupIndex) Cost() int { return 2 }
84-
85-
func (*lookupIndex) IsUnique() bool { return true }
86-
87-
func (*lookupIndex) NeedsVCursor() bool { return false }
88-
89-
func (*lookupIndex) Verify(context.Context, vindexes.VCursor, []sqltypes.Value, [][]byte) ([]bool, error) {
90-
return []bool{}, nil
91-
}
92-
93-
func (*lookupIndex) Map(ctx context.Context, vcursor vindexes.VCursor, ids []sqltypes.Value) ([]key.Destination, error) {
94-
return nil, nil
95-
}
96-
97-
func (*lookupIndex) Create(context.Context, vindexes.VCursor, [][]sqltypes.Value, [][]byte, bool) error {
98-
return nil
99-
}
100-
101-
func (*lookupIndex) Delete(context.Context, vindexes.VCursor, [][]sqltypes.Value, []byte) error {
102-
return nil
103-
}
104-
105-
func (*lookupIndex) Update(context.Context, vindexes.VCursor, []sqltypes.Value, []byte, []sqltypes.Value) error {
106-
return nil
107-
}
108-
109-
func newLookupIndex(name string, _ map[string]string) (vindexes.Vindex, error) {
110-
return &lookupIndex{name: name}, nil
111-
}
112-
113-
var _ vindexes.Lookup = (*lookupIndex)(nil)
114-
115-
// nameLkpIndex satisfies Lookup, NonUnique.
116-
type nameLkpIndex struct{ name string }
117-
118-
func (v *nameLkpIndex) String() string { return v.name }
119-
120-
func (*nameLkpIndex) Cost() int { return 3 }
121-
122-
func (*nameLkpIndex) IsUnique() bool { return false }
123-
124-
func (*nameLkpIndex) NeedsVCursor() bool { return false }
125-
126-
func (*nameLkpIndex) AllowBatch() bool { return true }
127-
128-
func (*nameLkpIndex) AutoCommitEnabled() bool { return false }
129-
130-
func (*nameLkpIndex) GetCommitOrder() vtgatepb.CommitOrder { return vtgatepb.CommitOrder_NORMAL }
131-
132-
func (*nameLkpIndex) Verify(context.Context, vindexes.VCursor, []sqltypes.Value, [][]byte) ([]bool, error) {
133-
return []bool{}, nil
134-
}
135-
136-
func (*nameLkpIndex) Map(ctx context.Context, vcursor vindexes.VCursor, ids []sqltypes.Value) ([]key.Destination, error) {
137-
return nil, nil
138-
}
139-
140-
func (*nameLkpIndex) Create(context.Context, vindexes.VCursor, [][]sqltypes.Value, [][]byte, bool) error {
141-
return nil
142-
}
143-
144-
func (*nameLkpIndex) Delete(context.Context, vindexes.VCursor, [][]sqltypes.Value, []byte) error {
145-
return nil
146-
}
147-
148-
func (*nameLkpIndex) Update(context.Context, vindexes.VCursor, []sqltypes.Value, []byte, []sqltypes.Value) error {
149-
return nil
150-
}
151-
152-
func (v *nameLkpIndex) Query() (string, []string) {
153-
return "select name, keyspace_id from name_user_vdx where name in ::name", []string{"name"}
154-
}
155-
156-
func (*nameLkpIndex) MapResult([]sqltypes.Value, []*sqltypes.Result) ([]key.Destination, error) {
157-
return nil, nil
158-
}
159-
160-
func newNameLkpIndex(name string, _ map[string]string) (vindexes.Vindex, error) {
161-
return &nameLkpIndex{name: name}, nil
162-
}
163-
164-
var _ vindexes.Vindex = (*nameLkpIndex)(nil)
165-
166-
var _ vindexes.Lookup = (*nameLkpIndex)(nil)
167-
168-
var _ vindexes.LookupPlanable = (*nameLkpIndex)(nil)
169-
170-
// costlyIndex satisfies Lookup, NonUnique.
171-
type costlyIndex struct{ name string }
172-
173-
func (v *costlyIndex) String() string { return v.name }
174-
175-
func (*costlyIndex) Cost() int { return 10 }
176-
177-
func (*costlyIndex) IsUnique() bool { return false }
178-
179-
func (*costlyIndex) NeedsVCursor() bool { return false }
180-
181-
func (*costlyIndex) Verify(context.Context, vindexes.VCursor, []sqltypes.Value, [][]byte) ([]bool, error) {
182-
return []bool{}, nil
183-
}
184-
185-
func (*costlyIndex) Map(ctx context.Context, vcursor vindexes.VCursor, ids []sqltypes.Value) ([]key.Destination, error) {
186-
return nil, nil
187-
}
188-
189-
func (*costlyIndex) Create(context.Context, vindexes.VCursor, [][]sqltypes.Value, [][]byte, bool) error {
190-
return nil
191-
}
192-
193-
func (*costlyIndex) Delete(context.Context, vindexes.VCursor, [][]sqltypes.Value, []byte) error {
194-
return nil
195-
}
196-
197-
func (*costlyIndex) Update(context.Context, vindexes.VCursor, []sqltypes.Value, []byte, []sqltypes.Value) error {
198-
return nil
199-
}
200-
201-
func newCostlyIndex(name string, _ map[string]string) (vindexes.Vindex, error) {
202-
return &costlyIndex{name: name}, nil
203-
}
204-
205-
var _ vindexes.Vindex = (*costlyIndex)(nil)
206-
207-
var _ vindexes.Lookup = (*costlyIndex)(nil)
208-
209-
// multiColIndex satisfies multi column vindex.
210-
type multiColIndex struct {
211-
name string
212-
}
213-
214-
func newMultiColIndex(name string, _ map[string]string) (vindexes.Vindex, error) {
215-
return &multiColIndex{name: name}, nil
216-
}
217-
218-
var _ vindexes.MultiColumn = (*multiColIndex)(nil)
219-
220-
func (m *multiColIndex) String() string { return m.name }
221-
222-
func (m *multiColIndex) Cost() int { return 1 }
223-
224-
func (m *multiColIndex) IsUnique() bool { return true }
225-
226-
func (m *multiColIndex) NeedsVCursor() bool { return false }
227-
228-
func (m *multiColIndex) Map(ctx context.Context, vcursor vindexes.VCursor, rowsColValues [][]sqltypes.Value) ([]key.Destination, error) {
229-
return nil, nil
230-
}
231-
232-
func (m *multiColIndex) Verify(ctx context.Context, vcursor vindexes.VCursor, rowsColValues [][]sqltypes.Value, ksids [][]byte) ([]bool, error) {
233-
return []bool{}, nil
234-
}
235-
236-
func (m *multiColIndex) PartialVindex() bool {
237-
return true
238-
}
239-
240-
func init() {
241-
vindexes.Register("hash_test", newHashIndex)
242-
vindexes.Register("lookup_test", newLookupIndex)
243-
vindexes.Register("name_lkp_test", newNameLkpIndex)
244-
vindexes.Register("costly", newCostlyIndex)
245-
vindexes.Register("multiCol_test", newMultiColIndex)
246-
}
247-
24855
func makeTestOutput(t *testing.T) string {
24956
testOutputTempDir := utils.MakeTestOutput(t, "testdata", "plan_test")
25057

0 commit comments

Comments
 (0)