-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kv: add error code for package kv #12866
Conversation
Codecov Report
@@ Coverage Diff @@
## master #12866 +/- ##
===========================================
Coverage 80.4066% 80.4066%
===========================================
Files 468 468
Lines 111946 111946
===========================================
Hits 90012 90012
Misses 15209 15209
Partials 6725 6725 |
This PR fixes two issues. One is to separate the error that was originally mapped to ErrUnknown 1105 into multiple error codes, and the other is to put https://github.com/pingcap/tidb/pull/12866/files#diff -7e048d4e2f4a505912ffd33bd900b6d3R43 is changed to ErrDupUnknownInIndex. The first one I think is ok, the second one, I think it needs to review. PTAL @zimulala @crazycs520 |
ddl/rollingback.go
Outdated
@@ -40,7 +40,7 @@ func convertAddIdxJob2RollbackJob(t *meta.Meta, job *model.Job, tblInfo *model.T | |||
} | |||
|
|||
if kv.ErrKeyExists.Equal(err) { | |||
return ver, kv.ErrKeyExists.GenWithStack("Duplicate for key %s", indexInfo.Name.O) | |||
return ver, ErrDupUnknownInIndex.GenWithStackByArgs(indexInfo.Name.O) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zimulala @crazycs520 PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this error code? ErrDupUnknownInIndex
error code is 1859.
mysql> select * from t;
+------+
| a |
+------+
| 1 |
| 1 |
+------+
2 rows in set (0.01 sec)
mysql> alter table t add unique index idx(a);
ERROR 1062 (23000): Duplicate entry '1' for key 'idx'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ver, ErrDupUnknownInIndex.GenWithStackByArgs(indexInfo.Name.O) | |
return ver, ErrKeyExists.GenWithStackByArgs("", indexInfo.Name.O) |
how about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL @zimulala
@@ -376,7 +376,7 @@ func extractKeyErr(keyErr *pb.KeyError) error { | |||
return newWriteConflictError(keyErr.Conflict) | |||
} | |||
if keyErr.Retryable != "" { | |||
return kv.ErrTxnRetryable.FastGenByArgs("tikv restarts txn: " + keyErr.GetRetryable()) | |||
return kv.ErrTxnRetryable.FastGenByArgs(keyErr.GetRetryable()) | |||
} | |||
if keyErr.Abort != "" { | |||
err := errors.Errorf("tikv aborts txn: %s", keyErr.GetAbort()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this error have an error code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but not in this plan. There are many similar problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Your auto merge job has been accepted, waiting for 13003, 12916 |
/run-all-tests |
@jackysp merge failed. |
/merge |
/run-all-tests |
@jackysp merge failed. |
/merge |
/run-all-tests |
@jackysp merge failed. |
/run-mybatis-test |
What problem does this PR solve?
Not all the errors in kv package have error code.
What is changed and how it works?
Add them. Related to pingcap/parser#584.
Check List
Tests
Code changes
Side effects