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

executor: fix unexpected 'invalid auto-id' error in pessimistic txn retry (#20123) #20134

Merged
merged 2 commits into from Sep 23, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #20123 to release-4.0


What problem does this PR solve?

Problem Summary:

In a high load cluster, the error [variable:8053]Cannot get a valid auto-ID when retrying the statement is reported frequently.

TiDB always reuse the allocated auto-ids in the retry stage by saving them to the session variable RetryInfo. At the beginning of retry, one should reset RetryInfo offset first to keep things correct.

Optimistic txn retries in the commit phase: session.retry().
Pessimistic txn retries when the statement is executed: ExecStmt.handlePessimisticDML.

ExecStmt.handlePessimisticDML does not reset RetryInfo offset, results in the auto-ids cannot be reused.

What is changed and how it works?

What's Changed: make ExecStmt.handlePessimisticDML reset RetryInfo offset.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test

Side effects

N/A

Release note

  • Fix unexpected 'invalid auto-id' error in pessimistic txn retry.

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@coocood
Copy link
Member

coocood commented Sep 23, 2020

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 23, 2020
Copy link
Member

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 23, 2020
@lzmhhh123
Copy link
Member

/merge

@ti-srebot
Copy link
Contributor Author

Sorry @lzmhhh123, you don't have permission to trigger auto merge event on this branch.
The version releasement is in progress.

@jebter
Copy link

jebter commented Sep 23, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 23, 2020
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot merged commit d1a152f into pingcap:release-4.0 Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants