Skip to content
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

Merged
merged 8 commits into from Nov 1, 2019
Merged

kv: add error code for package kv #12866

merged 8 commits into from Nov 1, 2019

Conversation

jackysp
Copy link
Member

@jackysp jackysp commented Oct 22, 2019

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

  • Unit test

Code changes

  • Has exported variable/fields change

Side effects

  • Breaking backward compatibility

@codecov
Copy link

codecov bot commented Oct 22, 2019

Codecov Report

Merging #12866 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #12866   +/-   ##
===========================================
  Coverage   80.4066%   80.4066%           
===========================================
  Files           468        468           
  Lines        111946     111946           
===========================================
  Hits          90012      90012           
  Misses        15209      15209           
  Partials       6725       6725

@jackysp
Copy link
Member Author

jackysp commented Oct 26, 2019

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

@@ -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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return ver, ErrDupUnknownInIndex.GenWithStackByArgs(indexInfo.Name.O)
return ver, ErrKeyExists.GenWithStackByArgs("", indexInfo.Name.O)

how about this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL @zimulala

@jackysp jackysp requested review from lysu and coocood October 26, 2019 04:05
@@ -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())
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jackysp jackysp added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 30, 2019
lysu
lysu previously approved these changes Oct 30, 2019
Copy link
Collaborator

@lysu lysu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lysu lysu added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 30, 2019
@jackysp jackysp added the status/can-merge Indicates a PR has been approved by a committer. label Oct 30, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 30, 2019

Your auto merge job has been accepted, waiting for 13003, 12916

@sre-bot
Copy link
Contributor

sre-bot commented Oct 30, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Oct 30, 2019

@jackysp merge failed.

lysu
lysu previously approved these changes Oct 30, 2019
@lysu
Copy link
Collaborator

lysu commented Oct 30, 2019

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Oct 30, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Oct 30, 2019

@jackysp merge failed.

@jackysp
Copy link
Member Author

jackysp commented Nov 1, 2019

/merge

@sre-bot
Copy link
Contributor

sre-bot commented Nov 1, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Nov 1, 2019

@jackysp merge failed.

@zyxbest
Copy link
Contributor

zyxbest commented Nov 1, 2019

/run-mybatis-test

@jackysp jackysp merged commit ff6a4f7 into pingcap:master Nov 1, 2019
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
@jackysp jackysp deleted the errors branch February 27, 2020 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants