From 5d34757e58e476d05bb22275492c6dc71eb9ef81 Mon Sep 17 00:00:00 2001 From: csuzhangxc Date: Wed, 16 Oct 2019 11:54:48 +0800 Subject: [PATCH] *: add two black DML cases for auto recovery; fix panic when commit DML txn failed --- dm/worker/task_checker.go | 9 +++++++++ dm/worker/task_checker_test.go | 2 ++ pkg/baseconn/conn.go | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dm/worker/task_checker.go b/dm/worker/task_checker.go index e5fbc4ceaa..462fc2e645 100644 --- a/dm/worker/task_checker.go +++ b/dm/worker/task_checker.go @@ -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", @@ -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) { diff --git a/dm/worker/task_checker_test.go b/dm/worker/task_checker_test.go index ab19ff5baf..b223b0ad12 100644 --- a/dm/worker/task_checker_test.go +++ b/dm/worker/task_checker_test.go @@ -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}, diff --git a/pkg/baseconn/conn.go b/pkg/baseconn/conn.go index 423031e8a0..81a3918e4d 100644 --- a/pkg/baseconn/conn.go +++ b/pkg/baseconn/conn.go @@ -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 }