Skip to content

Commit 883df02

Browse files
committed
Run VStream copy only when VGTID requires it, use TablesToCopy in those cases (vitessio#18938)
Signed-off-by: twthorn <thomaswilliamthornton@gmail.com> Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com> Signed-off-by: Thomas Thornton <thomaswilliamthornton@gmail.com>
1 parent c11d94a commit 883df02

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

go/vt/vttablet/tabletserver/vstreamer/uvstreamer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,10 @@ func (uvs *uvstreamer) currentPosition() (replication.Position, error) {
417417
// 3. TablePKs not nil, startPos empty => table copy (for pks > lastPK)
418418
// 4. TablePKs not nil, startPos set => run catchup from startPos, then table copy (for pks > lastPK)
419419
//
420-
// If TablesToCopy option is not nil, copy only the tables listed in TablesToCopy.
421-
// For other tables not in TablesToCopy, if startPos is set, perform catchup starting from startPos.
420+
// If table copy phase should run based on one of the previous states, then only copy the tables in
421+
// TablesToCopy list.
422422
func (uvs *uvstreamer) init() error {
423-
if uvs.startPos == "" /* full copy */ || len(uvs.inTablePKs) > 0 /* resume copy */ || len(uvs.options.GetTablesToCopy()) > 0 /* copy specific tables */ {
423+
if uvs.startPos == "" /* full copy */ || len(uvs.inTablePKs) > 0 /* resume copy */ {
424424
if err := uvs.buildTablePlan(); err != nil {
425425
return err
426426
}

go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,3 +2307,30 @@ func TestFilteredIsNullOperator(t *testing.T) {
23072307
})
23082308
}
23092309
}
2310+
2311+
func TestUVStreamerNoCopyWithGTID(t *testing.T) {
2312+
execStatements(t, []string{
2313+
"create table t1(id int, val varchar(128), primary key(id))",
2314+
"insert into t1 values (1, 'val1')",
2315+
})
2316+
defer execStatements(t, []string{
2317+
"drop table t1",
2318+
})
2319+
ctx := context.Background()
2320+
filter := &binlogdatapb.Filter{
2321+
Rules: []*binlogdatapb.Rule{{
2322+
Match: "t1",
2323+
Filter: "select * from t1",
2324+
}},
2325+
}
2326+
pos := primaryPosition(t)
2327+
options := &binlogdatapb.VStreamOptions{
2328+
TablesToCopy: []string{"t1"},
2329+
}
2330+
uvs := newUVStreamer(ctx, engine, env.Dbcfgs.DbaWithDB(), env.SchemaEngine, pos,
2331+
nil, filter, testLocalVSchema, throttlerapp.VStreamerName,
2332+
func([]*binlogdatapb.VEvent) error { return nil }, options)
2333+
err := uvs.init()
2334+
require.NoError(t, err)
2335+
require.Empty(t, uvs.plans, "Should not build table plans when startPos is set")
2336+
}

0 commit comments

Comments
 (0)