tidb
tidb copied to clipboard
txn: add db name and table name in write conflict error message
Signed-off-by: ekexium [email protected]
What problem does this PR solve?
Issue Number: close #37257
Problem Summary:
What is changed and how it works?
The decoded row handle or index values are already there, so this PR adds db names and table names when possible.
Due to the limit of the current error handling framework (lack of structured info in a generated Error type), the implementation is dirty. It separates the key info into 4 parts in the error message. When TiDB is able to use infoschema to find the table, it parses the error message to find the table id and generate a new error.
Now a write conflict error message looks like
(9007, 'Write conflict, txnStartTS=436140757050982401, conflictStartTS=436140759711481857, conflictCommitTS=436140759711481858, key={tableID=70, tableName=test.t, handle=7} primary={tableID=70, tableName=test.t, handle=6}, reason=Optimistic [try again later]')
Check List
Tests
- [x] Unit test
- [ ] Integration test
- [x] Manual test (add detailed scripts or steps below)
- [ ] No code
Side effects
- [ ] Performance regression: Consumes more CPU
- [ ] Performance regression: Consumes more Memory
- [ ] Breaking backward compatibility
Documentation
- [ ] Affects user behaviors
- [ ] Contains syntax changes
- [ ] Contains variable changes
- [ ] Contains experimental features
- [ ] Changes MySQL compatibility
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
None
[REVIEW NOTIFICATION]
This pull request has been approved by:
- cfzjywxk
- sticnarf
To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.
The full list of commands accepted by this bot can be found here.
Reviewer can indicate their review by submitting an approval review. Reviewer can cancel approval by submitting a request changes review.
ErrWriteConflict error is used in so many places, but this PR replaces only the ErrWriteConflict in commit retry, is it ok ?
ErrWriteConflicterror is used in so many places, but this PR replaces only theErrWriteConflictin commit retry, is it ok ?
I think it's on the critical path of returning a write conflict error to user. So I suppose it's enough. Did I miss anything?
ErrWriteConflicterror is used in so many places, but this PR replaces only theErrWriteConflictin commit retry, is it ok ?I think it's on the critical path of returning a write conflict error to user. So I suppose it's enough. Did I miss anything?
I worried about that if the sql statements execution meets a writeconfilict error and returns the error directly, but I can't find the case. when retry count is more than PessimisticTxn.MaxRetryCount, it returns the error made by errors.New("pessimistic lock retry limit reached but not ErrWriteConflict.
So, I can't find what you missed.
/run-check_dev
/run-build /run-check-dev /run-check-dev2 /run-unit-test
/run-check_dev /run-check_dev2
/run-check_dev
I can't find other problem, LGTM.
@TonsnakeLin: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.
Will it work fine with a common handle?
Will it work fine with a common handle?
It does. Though the decoded handle is not easy to interpret.
/merge
This pull request has been accepted and is ready to merge.
@ekexium TestWriteConflictPrettyFormat fails because you add the key to the error.
Oops
/merge
This pull request has been accepted and is ready to merge.
/run-check-dev
@ekexium Probably the CI failure is caused by your stale bazel file?
/run-check_dev
/run-check_dev /run-unit-test
/run-build
@sticnarf Could you help merge it?
/merge
This pull request has been accepted and is ready to merge.
TiDB MergeCI notify
✅ Well Done! New fixed [3] after this pr merged.
| CI Name | Result | Duration | Compare with Parent commit |
|---|---|---|---|
| idc-jenkins-ci-tidb/integration-ddl-test | ✅ all 6 tests passed | 32 min | Fixed |
| idc-jenkins-ci-tidb/integration-common-test | ✅ all 17 tests passed | 17 min | Fixed |
| idc-jenkins-ci-tidb/integration-compatibility-test | ✅ all 1 tests passed | 3 min 5 sec | Fixed |
| idc-jenkins-ci/integration-cdc-test | 🟢 all 37 tests passed | 28 min | Existing passed |
| idc-jenkins-ci-tidb/tics-test | 🟢 all 1 tests passed | 12 min | Existing passed |
| idc-jenkins-ci-tidb/common-test | 🟢 all 11 tests passed | 9 min 56 sec | Existing passed |
| idc-jenkins-ci-tidb/sqllogic-test-2 | 🟢 all 28 tests passed | 7 min 12 sec | Existing passed |
| idc-jenkins-ci-tidb/sqllogic-test-1 | 🟢 all 26 tests passed | 6 min 49 sec | Existing passed |
| idc-jenkins-ci-tidb/mybatis-test | 🟢 all 1 tests passed | 2 min 52 sec | Existing passed |
| idc-jenkins-ci-tidb/plugin-test | 🟢 build success, plugin test success | 4min | Existing passed |