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

Commit

Permalink
*: add two black DML cases for auto recovery; fix panic when commit D…
Browse files Browse the repository at this point in the history
…ML txn failed (#313)
  • Loading branch information
sre-bot authored and csuzhangxc committed Oct 16, 2019
1 parent d65b307 commit 3add674
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dm/worker/task_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ func isResumableError(err *pb.ProcessError) bool {
"unsupported modify",
"unsupported drop integer primary key",
}
unsupportedDMLMsgs := []string{
"Error 1062: Duplicate entry",
"Error 1406: Data too long for column",
}
parseRelayLogErrMsg := []string{
"binlog checksum mismatch, data may be corrupted",
"get event err EOF",
Expand All @@ -252,6 +256,11 @@ func isResumableError(err *pb.ProcessError) bool {
return false
}
}
for _, msg := range unsupportedDMLMsgs {
if strings.Contains(err.Msg, msg) {
return false
}
}
case pb.ErrorType_UnknownError:
// TODO: we need better mechanism to convert error in `ProcessError` to `terror.Error`
if strings.Contains(err.Msg, parseRelayLogCode) {
Expand Down
2 changes: 2 additions & 0 deletions dm/worker/task_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ func (s *testTaskCheckerSuite) TestIsResumableError(c *check.C) {
{&pb.ProcessError{Type: pb.ErrorType_ExecSQL, Msg: "ERROR 1105 (HY000): unsupported drop integer primary key"}, false},
{&pb.ProcessError{Type: pb.ErrorType_ExecSQL, Msg: ""}, true},
{&pb.ProcessError{Type: pb.ErrorType_ExecSQL, Msg: "[code=10006:class=database:scope=not-set:level=high] file test.t3.sql: execute statement failed: USE `test_abc`;: context canceled"}, true},
{&pb.ProcessError{Type: pb.ErrorType_ExecSQL, Msg: "[code=10006:class=database:scope=not-set:level=high] execute statement failed: commit: Error 1062: Duplicate entry '5' for key 'PRIMARY'"}, false},
{&pb.ProcessError{Type: pb.ErrorType_ExecSQL, Msg: "[code=10006:class=database:scope=not-set:level=high] execute statement failed: INSERT INTO `db`.`tbl` (`c1`,`c2`) VALUES (?,?);: Error 1406: Data too long for column 'c2' at row 1"}, false},
{&pb.ProcessError{Type: pb.ErrorType_UnknownError, Msg: "[code=11038:class=functional:scope=internal:level=high] 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.ProcessError{Type: pb.ErrorType_UnknownError, Msg: "[code=11038:class=functional:scope=internal:level=high] 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},
{&pb.ProcessError{Type: pb.ErrorType_UnknownError, Msg: ""}, true},
Expand Down
2 changes: 1 addition & 1 deletion pkg/baseconn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (conn *BaseConn) ExecuteSQLWithIgnoreError(tctx *tcontext.Context, ignoreEr
}
err = txn.Commit()
if err != nil {
return l, terror.ErrDBExecuteFailed.Delegate(err, "commit")
return l - 1, terror.ErrDBExecuteFailed.Delegate(err, "commit") // mark failed on the last one
}
return l, nil
}
Expand Down

0 comments on commit 3add674

Please sign in to comment.