Skip to content

Commit

Permalink
fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
buchuitoudegou committed Dec 9, 2022
1 parent db15bf3 commit 6d0cfd6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions dumpling/export/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ go_library(
"@com_github_coreos_go_semver//semver",
"@com_github_docker_go_units//:go-units",
"@com_github_go_sql_driver_mysql//:mysql",
"@com_github_google_uuid//:uuid",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_log//:log",
Expand Down
5 changes: 2 additions & 3 deletions dumpling/export/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ func NewDumper(ctx context.Context, conf *Config) (*Dumper, error) {
failpoint.Inject("SetIOTotalBytes", func(_ failpoint.Value) {
d.conf.IOTotalBytes = gatomic.NewUint64(0)
d.conf.Net = uuid.New().String()
d.conf.Logger = log.Zap().Logger
go func() {
for {
time.Sleep(10 * time.Millisecond)
d.conf.Logger.Info("IOTotalBytes", zap.Uint64("IOTotalBytes", d.conf.IOTotalBytes.Load()))
d.tctx.L().Logger.Info("IOTotalBytes", zap.Uint64("IOTotalBytes", d.conf.IOTotalBytes.Load()))
}
}()
})
Expand Down Expand Up @@ -1357,7 +1356,7 @@ func openSQLDB(d *Dumper) error {
// try https://github.com/go-sql-driver/mysql/blob/bcc459a906419e2890a50fc2c99ea6dd927a88f2/connector.go#L56-L64
err = tcpConn.SetKeepAlive(true)
if err != nil {
return nil, err
d.tctx.L().Logger.Warn("fail to keep alive", zap.Error(err))
}
return util.NewTCPConnWithIOCounter(tcpConn, d.conf.IOTotalBytes), nil
})
Expand Down
3 changes: 2 additions & 1 deletion dumpling/tests/basic/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,5 @@ run_sql "insert into test_db.test_table values (1),(2),(3),(4),(5),(6),(7),(8);"

export GO_FAILPOINTS="github.com/pingcap/tidb/dumpling/export/SetIOTotalBytes=return(1)"
run_dumpling -B "test_db" -L ${DUMPLING_OUTPUT_DIR}/dumpling.log
grep 'IOTotal' ${DUMPLING_OUTPUT_DIR}/dumpling.log | grep -v 'IOTotalBytes=0'
cnt=$(grep "IOTotalBytes=" ${DUMPLING_OUTPUT_DIR}/dumpling.log | grep -v "IOTotalBytes=0" | wc -l)
[ "$cnt" -ge 1 ]

0 comments on commit 6d0cfd6

Please sign in to comment.