Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go/vt/vttablet/tabletserver/vstreamer/uvstreamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ func (uvs *uvstreamer) currentPosition() (replication.Position, error) {
// 3. TablePKs not nil, startPos empty => table copy (for pks > lastPK)
// 4. TablePKs not nil, startPos set => run catchup from startPos, then table copy (for pks > lastPK)
//
// If TablesToCopy option is not nil, copy only the tables listed in TablesToCopy.
// For other tables not in TablesToCopy, if startPos is set, perform catchup starting from startPos.
// If table copy phase should run based on one of the previous states, then only copy the tables in
// TablesToCopy list.
func (uvs *uvstreamer) init() error {
if uvs.startPos == "" /* full copy */ || len(uvs.inTablePKs) > 0 /* resume copy */ || len(uvs.options.GetTablesToCopy()) > 0 /* copy specific tables */ {
if uvs.startPos == "" /* full copy */ || len(uvs.inTablePKs) > 0 /* resume copy */ {
if err := uvs.buildTablePlan(); err != nil {
return err
}
Expand Down
55 changes: 55 additions & 0 deletions go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Copyright 2019 The Vitess Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package vstreamer

import (
"context"
"testing"

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/vt/vttablet/tabletserver/throttle/throttlerapp"

binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
)

func TestUVStreamerNoCopyWithGTID(t *testing.T) {
execStatements(t, []string{
"create table t1(id int, val varchar(128), primary key(id))",
"insert into t1 values (1, 'val1')",
})
defer execStatements(t, []string{
"drop table t1",
})
ctx := context.Background()
filter := &binlogdatapb.Filter{
Rules: []*binlogdatapb.Rule{{
Match: "t1",
Filter: "select * from t1",
}},
}
pos := primaryPosition(t)
options := &binlogdatapb.VStreamOptions{
TablesToCopy: []string{"t1"},
}
uvs := newUVStreamer(ctx, engine, env.Dbcfgs.DbaWithDB(), env.SchemaEngine, pos,
nil, filter, testLocalVSchema, throttlerapp.VStreamerName,
func([]*binlogdatapb.VEvent) error { return nil }, options)
err := uvs.init()
require.NoError(t, err)
require.Empty(t, uvs.plans, "Should not build table plans when startPos is set")
}
Loading