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

*: cherry pick 741; update terror codes #742

Merged
merged 7 commits into from
Jun 17, 2020
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
bin
*/*.iml
.idea/
*/.idea
deps.sh
syncer.meta
Expand All @@ -8,6 +9,7 @@ dm-worker.log*
dm-master.log*
dmctl.log
relay_log/*
/_tools/
vendor
*/*.DS_Store
tidb-slow.log
78 changes: 65 additions & 13 deletions _utils/terror_gen/errors_release.txt

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ func (c *Checker) Init(ctx context.Context) (err error) {
for _, instance := range c.instances {
bw, err := filter.New(instance.cfg.CaseSensitive, instance.cfg.BWList)
if err != nil {
return terror.ErrTaskCheckNewBWList.Delegate(err)
return terror.ErrTaskCheckGenBWList.Delegate(err)
}
r, err := router.NewTableRouter(instance.cfg.CaseSensitive, instance.cfg.RouteRules)
if err != nil {
return terror.ErrTaskCheckNewTableRouter.Delegate(err)
return terror.ErrTaskCheckGenTableRouter.Delegate(err)
}

columnMapping[instance.cfg.SourceID], err = column.NewMapping(instance.cfg.CaseSensitive, instance.cfg.ColumnMappingRules)
if err != nil {
return terror.ErrTaskCheckNewColumnMapping.Delegate(err)
return terror.ErrTaskCheckGenColumnMapping.Delegate(err)
}

instance.sourceDBinfo = &dbutil.DBConfig{
Expand Down
2 changes: 1 addition & 1 deletion checker/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func CheckSyncConfig(ctx context.Context, cfgs []*config.SubTaskConfig) error {
r := <-pr
// we only want first error
if len(r.Errors) > 0 {
return terror.ErrTaskCheckSyncConfigError.Generate(ErrorMsgHeader, r.Errors[0].Type, r.Errors[0].Msg, string(r.Detail))
return terror.ErrTaskCheckSyncConfigError.Generate(ErrorMsgHeader, r.Errors[0].Msg, string(r.Detail))
}
}

Expand Down
4 changes: 2 additions & 2 deletions dm/worker/subtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func (st *SubTask) Close() {
// Pause pauses the running sub task
func (st *SubTask) Pause() error {
if !st.stageCAS(pb.Stage_Running, pb.Stage_Paused) {
return terror.ErrWorkerNotRunningStage.Generate()
return terror.ErrWorkerNotRunningStage.Generate(st.Stage().String())
}

st.callCurrCancel()
Expand All @@ -448,7 +448,7 @@ func (st *SubTask) Resume() error {
}

if !st.stageCAS(pb.Stage_Paused, pb.Stage_Running) {
return terror.ErrWorkerNotPausedStage.Generate()
return terror.ErrWorkerNotPausedStage.Generate(st.Stage().String())
}
ctx, cancel := context.WithCancel(st.ctx)
st.setCurrCtx(ctx, cancel)
Expand Down
4 changes: 4 additions & 0 deletions dm/worker/task_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ func (s *testTaskCheckerSuite) TestIsResumableError(c *check.C) {
// real error is generated by `Delegate` and multiple `Annotatef`, we use `New` to simplify it
{pb.ErrorType_UnknownError, terror.ErrParserParseRelayLog.New("parse relay log file bin.000018 from offset 555 in dir /home/tidb/deploy/relay_log/d2e831df-b4ec-11e9-9237-0242ac110008.000004: parse relay log file bin.000018 from offset 0 in dir /home/tidb/deploy/relay_log/d2e831df-b4ec-11e9-9237-0242ac110008.000004: parse relay log file /home/tidb/deploy/relay_log/d2e831df-b4ec-11e9-9237-0242ac110008.000004/bin.000018: binlog checksum mismatch, data may be corrupted"), false},
{pb.ErrorType_UnknownError, terror.ErrParserParseRelayLog.New("parse relay log file bin.000018 from offset 500 in dir /home/tidb/deploy/relay_log/d2e831df-b4ec-11e9-9237-0242ac110008.000004: parse relay log file bin.000018 from offset 0 in dir /home/tidb/deploy/relay_log/d2e831df-b4ec-11e9-9237-0242ac110008.000004: parse relay log file /home/tidb/deploy/relay_log/d2e831df-b4ec-11e9-9237-0242ac110008.000004/bin.000018: get event err EOF, need 1567488104 but got 316323"), false},
// unresumable terror codes
{pb.ErrorType_UnknownError, terror.ErrSyncUnitDDLWrongSequence.Generate("wrong sequence", "right sequence"), false},
{pb.ErrorType_UnknownError, terror.ErrSyncerShardDDLConflict.Generate("conflict DDL"), false},
// others
{pb.ErrorType_UnknownError, nil, true},
{pb.ErrorType_UnknownError, errors.New("unknown error"), true},
}
Expand Down
8 changes: 4 additions & 4 deletions loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func (l *Loader) Init(ctx context.Context) (err error) {

l.bwList, err = filter.New(l.cfg.CaseSensitive, l.cfg.BWList)
if err != nil {
return terror.ErrLoadUnitNewBWList.Delegate(err)
return terror.ErrLoadUnitGenBWList.Delegate(err)
}

if l.cfg.RemoveMeta {
Expand All @@ -440,7 +440,7 @@ func (l *Loader) Init(ctx context.Context) (err error) {
if len(l.cfg.ColumnMappingRules) > 0 {
l.columnMapping, err = cm.NewMapping(l.cfg.CaseSensitive, l.cfg.ColumnMappingRules)
if err != nil {
return terror.ErrLoadUnitNewColumnMapping.Delegate(err)
return terror.ErrLoadUnitGenColumnMapping.Delegate(err)
}
}

Expand Down Expand Up @@ -728,7 +728,7 @@ func (l *Loader) Update(cfg *config.SubTaskConfig) error {
oldBwList = l.bwList
l.bwList, err = filter.New(cfg.CaseSensitive, cfg.BWList)
if err != nil {
return terror.ErrLoadUnitNewBWList.Delegate(err)
return terror.ErrLoadUnitGenBWList.Delegate(err)
}

// update route, for loader, this almost useless, because schemas often have been restored
Expand All @@ -742,7 +742,7 @@ func (l *Loader) Update(cfg *config.SubTaskConfig) error {
oldColumnMapping = l.columnMapping
l.columnMapping, err = cm.NewMapping(cfg.CaseSensitive, cfg.ColumnMappingRules)
if err != nil {
return terror.ErrLoadUnitNewColumnMapping.Delegate(err)
return terror.ErrLoadUnitGenColumnMapping.Delegate(err)
}

// update l.cfg
Expand Down
2 changes: 1 addition & 1 deletion pkg/encrypt/encrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func SetSecretKey(key []byte) error {
func Encrypt(plaintext []byte) ([]byte, error) {
block, err := aes.NewCipher(secretKey)
if err != nil {
return nil, terror.ErrEncryptNewCipher.Delegate(err)
return nil, terror.ErrEncryptGenCipher.Delegate(err)
}

iv, err := genIV(block.BlockSize())
Expand Down
1 change: 1 addition & 0 deletions pkg/retry/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var (
// UnresumableErrCodes is a set of unresumeable err codes.
UnresumableErrCodes = map[int32]struct{}{
int32(terror.ErrSyncUnitDDLWrongSequence.Code()): {},
int32(terror.ErrSyncerShardDDLConflict.Code()): {},
}
)

Expand Down
Loading