Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vstreamer: bug fix on mysql connection #4837

Merged
merged 1 commit into from
Apr 24, 2019
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
5 changes: 4 additions & 1 deletion go/vt/vttablet/tabletmanager/vreplication/vplayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,10 @@ func TestPlayerDDL(t *testing.T) {

execStatements(t, []string{"alter table t1 add column val varchar(128)"})
execStatements(t, []string{"alter table t1 drop column val"})
expectDBClientQueries(t, []string{"/update _vt.vreplication set pos="})
expectDBClientQueries(t, []string{
"/update _vt.vreplication set pos=",
"/update _vt.vreplication set pos=",
})
cancel()

cancel, id := startVReplication(t, filter, binlogdatapb.OnDDLAction_STOP, "")
Expand Down
13 changes: 11 additions & 2 deletions go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/dbconfigs"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/vtgate/vindexes"
"vitess.io/vitess/go/vt/vttablet/tabletserver/schema"
Expand Down Expand Up @@ -76,7 +77,7 @@ func (rs *rowStreamer) Stream() error {
return err
}

conn, err := mysql.Connect(rs.ctx, rs.cp)
conn, err := rs.mysqlConnect()
if err != nil {
return err
}
Expand Down Expand Up @@ -259,7 +260,7 @@ func (rs *rowStreamer) streamQuery(conn *mysql.Conn, send func(*binlogdatapb.VSt
}

func (rs *rowStreamer) lockTable() (unlock func() error, gtid string, err error) {
conn, err := mysql.Connect(rs.ctx, rs.cp)
conn, err := rs.mysqlConnect()
if err != nil {
return nil, "", err
}
Expand All @@ -286,3 +287,11 @@ func (rs *rowStreamer) lockTable() (unlock func() error, gtid string, err error)
}
return unlock, mysql.EncodePosition(pos), nil
}

func (rs *rowStreamer) mysqlConnect() (*mysql.Conn, error) {
cp, err := dbconfigs.WithCredentials(rs.cp)
if err != nil {
return nil, err
}
return mysql.Connect(rs.ctx, cp)
}
10 changes: 5 additions & 5 deletions go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ func TestREKeyRange(t *testing.T) {
})
engine.se.Reload(context.Background())

if err := env.SetVSchema(shardedVSchema); err != nil {
t.Fatal(err)
}
defer env.SetVSchema("{}")

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand All @@ -199,11 +204,6 @@ func TestREKeyRange(t *testing.T) {
}
ch := startStream(ctx, t, filter)

if err := env.SetVSchema(shardedVSchema); err != nil {
t.Fatal(err)
}
defer env.SetVSchema("{}")

// 1, 2, 3 and 5 are in shard -80.
// 4 and 6 are in shard 80-.
input := []string{
Expand Down