Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
syncer: update dependency to avoid exit when meet unsupported binlog (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jun 8, 2021
1 parent 3963412 commit 11bdda2
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 5 deletions.
1 change: 1 addition & 0 deletions _utils/terror_gen/errors_release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ ErrSyncerOperatorNotExist,[code=36065:class=sync-unit:scope=internal:level=low],
ErrSyncerReplaceEventNotExist,[code=36066:class=sync-unit:scope=internal:level=high], "Message: replace event not exist, location: %s"
ErrSyncerParseDDL,[code=36067:class=sync-unit:scope=internal:level=high], "Message: parse DDL: %s, Workaround: Please confirm your DDL statement is correct and needed. For TiDB compatible DDL, see https://docs.pingcap.com/tidb/stable/mysql-compatibility#ddl. You can use `handle-error` command to skip or replace the DDL or add a binlog filter rule to ignore it if the DDL is not needed."
ErrSyncerUnsupportedStmt,[code=36068:class=sync-unit:scope=internal:level=high], "Message: `%s` statement not supported in %s mode"
ErrSyncerGetEvent,[code=36069:class=sync-unit:scope=upstream:level=high], "Message: get binlog event error: %v, Workaround: Please check if the binlog file could be parsed by `mysqlbinlog`."
ErrMasterSQLOpNilRequest,[code=38001:class=dm-master:scope=internal:level=medium], "Message: nil request not valid"
ErrMasterSQLOpNotSupport,[code=38002:class=dm-master:scope=internal:level=medium], "Message: op %s not supported"
ErrMasterSQLOpWithoutSharding,[code=38003:class=dm-master:scope=internal:level=medium], "Message: operate request without --sharding specified not valid"
Expand Down
6 changes: 6 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1924,6 +1924,12 @@ description = ""
workaround = ""
tags = ["internal", "high"]

[error.DM-sync-unit-36069]
message = "get binlog event error: %v"
description = ""
workaround = "Please check if the binlog file could be parsed by `mysqlbinlog`."
tags = ["upstream", "high"]

[error.DM-dm-master-38001]
message = "nil request not valid"
description = ""
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/coreos/go-semver v0.3.0
github.com/docker/go-units v0.4.0
github.com/dustin/go-humanize v1.0.0
github.com/go-mysql-org/go-mysql v1.1.3-0.20210420093540-a51d9dec4f96
github.com/go-mysql-org/go-mysql v1.1.3-0.20210519094347-5ec8d511f5be
github.com/go-sql-driver/mysql v1.5.0
github.com/gogo/gateway v1.1.0
github.com/gogo/protobuf v1.3.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-mysql-org/go-mysql v1.1.3-0.20210420093540-a51d9dec4f96 h1:+0HKUBVZNwqh+k20hbdiFoZQ7neXijUm54G/B2cQVgM=
github.com/go-mysql-org/go-mysql v1.1.3-0.20210420093540-a51d9dec4f96/go.mod h1:3lFZKf7l95Qo70+3XB2WpiSf9wu2s3na3geLMaIIrqQ=
github.com/go-mysql-org/go-mysql v1.1.3-0.20210519094347-5ec8d511f5be h1:12z4p/lldNvXStdf2qPICQ3eyTC0B0kw32X8ysx40Yk=
github.com/go-mysql-org/go-mysql v1.1.3-0.20210519094347-5ec8d511f5be/go.mod h1:3lFZKf7l95Qo70+3XB2WpiSf9wu2s3na3geLMaIIrqQ=
github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI=
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
Expand Down
2 changes: 2 additions & 0 deletions pkg/terror/error_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ const (
codeSyncerReplaceEventNotExist
codeSyncerParseDDL
codeSyncerUnsupportedStmt
codeSyncerGetEvent
)

// DM-master error code.
Expand Down Expand Up @@ -1005,6 +1006,7 @@ var (
ErrSyncerReplaceEventNotExist = New(codeSyncerReplaceEventNotExist, ClassSyncUnit, ScopeInternal, LevelHigh, "replace event not exist, location: %s", "")
ErrSyncerParseDDL = New(codeSyncerParseDDL, ClassSyncUnit, ScopeInternal, LevelHigh, "parse DDL: %s", "Please confirm your DDL statement is correct and needed. For TiDB compatible DDL, see https://docs.pingcap.com/tidb/stable/mysql-compatibility#ddl. You can use `handle-error` command to skip or replace the DDL or add a binlog filter rule to ignore it if the DDL is not needed.")
ErrSyncerUnsupportedStmt = New(codeSyncerUnsupportedStmt, ClassSyncUnit, ScopeInternal, LevelHigh, "`%s` statement not supported in %s mode", "")
ErrSyncerGetEvent = New(codeSyncerGetEvent, ClassSyncUnit, ScopeUpstream, LevelHigh, "get binlog event error: %v", "Please check if the binlog file could be parsed by `mysqlbinlog`.")

// DM-master error.
ErrMasterSQLOpNilRequest = New(codeMasterSQLOpNilRequest, ClassDMMaster, ScopeInternal, LevelMedium, "nil request not valid", "")
Expand Down
4 changes: 4 additions & 0 deletions syncer/streamer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package syncer

import (
"context"
"errors"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -249,6 +250,9 @@ func (c *StreamerController) GetEvent(tctx *tcontext.Context) (event *replicatio

event, err = streamer.GetEvent(ctx)
cancel()
failpoint.Inject("GetEventError", func() {
err = errors.New("go-mysql returned an error")
})
if err != nil {
if err != context.Canceled && err != context.DeadlineExceeded {
c.Lock()
Expand Down
3 changes: 2 additions & 1 deletion syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,7 @@ func (s *Syncer) Run(ctx context.Context) (err error) {
}

if err != nil {
// TODO: wrap the error with terror, and attach binlog position
tctx.L().Error("fail to fetch binlog", log.ShortError(err))

if isConnectionRefusedError(err) {
Expand All @@ -1346,7 +1347,7 @@ func (s *Syncer) Run(ctx context.Context) (err error) {
continue
}

return err
return terror.ErrSyncerGetEvent.Generate(err)
}

// time duration for reading an event from relay log or upstream master.
Expand Down
17 changes: 16 additions & 1 deletion tests/incremental_mode/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,27 @@ function run() {
sed -i "s/binlog-pos-placeholder-2/$pos2/g" $WORK_DIR/dm-task.yaml
sed -i "s/binlog-gtid-placeholder-2/$gtid2/g" $WORK_DIR/dm-task.yaml

# test graceful display error
export GO_FAILPOINTS="github.com/pingcap/dm/syncer/GetEventError=return()"
run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml
check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT
run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml
check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER2_PORT
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"start-task $WORK_DIR/dm-task.yaml --remove-meta"
run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"query-status test" \
"\"ErrCode\": 36069" 2

kill_dm_worker
check_port_offline $WORKER1_PORT 20
check_port_offline $WORKER2_PORT 20

export GO_FAILPOINTS="github.com/pingcap/dm/syncer/WaitUserCancel=return(8)"
run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml
check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT
run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml
check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER2_PORT
dmctl_start_task $WORK_DIR/dm-task.yaml --remove-meta

# check not specify binlog name could also update active relay log
if [ $worker1_run_source_1 -gt 0 ]; then
Expand Down

0 comments on commit 11bdda2

Please sign in to comment.