-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: pessimistic lock on the temporary table should not be written to TiKV #24737
executor: pessimistic lock on the temporary table should not be written to TiKV #24737
Conversation
can we revert #24540 now? |
Or just remove the code that doing duplicated calculation to save CPU? |
/run-check_dev |
bc286f1
to
6364a82
Compare
/lgtm |
/lgtm |
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by writing |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 6364a82
|
@tiancaiamao: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. 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. |
What problem does this PR solve?
Avoid any kind of (pessimistic) lock on the temporary table been written to TiKV
Problem Summary:
What is changed and how it works?
The concept of "lock" is complex.
Basically, it means lock for the read operation.
We use MVCC and the transaction isolation level is actually "snapshot isolation", there are locks for the write operation but no locks for the read operation.
"write skew" is problem in "snapshot isolation". To overcome it, we provide "select ... for update" which also lock for read and can be used to fix the "write skew" problem.
From TiDB 3.0, we start to support the pessimistic transaction mode.
Pessimistic transaction differs from the optimistic transaction that it write locks to the TiKV immediately, instead of caching the changes in memory and write to TiKV until commit.
(batch) point get is a special code path for performance optimization.
With two different implementation, we have to take special care to maintain the different code path.
And for the pessimistic transaction, there are some minor behaviour differences between point get / non-point get request.
Under any circumstance, operations on the temporary table should not write locks to the TiKV.
In #24540 we cover the point get and batch point get.
However, there are
2*2*2
= 8 combinations in total, to cover them all, I chose the common code path.What's Changed:
Filter out the keys belong to the temporary table in
doLockKeys()
, all the pessimistic mode lock goes through this code path.How it Works:
All the optimistic mode lock should have already been filtered before the 2PC commit in PR #24196.
So all the cases are covered after this PR.
Check List
Tests
Release note