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
txn: Add batch-resumed mode for acquire_pessimistic_lock storage command #13687
txn: Add batch-resumed mode for acquire_pessimistic_lock storage command #13687
Conversation
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
[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 submitting an approval review. |
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
…into m/support-lock-with-conflictt
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
…lock-with-conflictt
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
…on-of-pessimistic-lock-command
…med-version-of-pessimistic-lock-command
I think it looks better to add a new command. Is there any difficulty doing this way? |
No. At first I was trying to reuse most of the code, but finally it looks totally different. I'll split it into two commands. |
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
src/storage/txn/commands/macros.rs
Outdated
($field: ident: enum_match { $( $arm: pat => $expr: expr ), * }) => { | ||
fn gen_lock(&self) -> crate::storage::txn::latch::Lock { | ||
match &self.$field { | ||
$( $arm => crate::storage::txn::latch::Lock::new($expr) ),* | ||
} | ||
} | ||
} |
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.
Where is this rule used?
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.
Ah sorry. This is not used now and I forgot to delete it.
if let Some(txn) = txn { | ||
if !txn.is_empty() { | ||
modifies.extend(txn.into_modifies()); | ||
} | ||
} | ||
txn = Some(MvccTxn::new( | ||
params.start_ts, | ||
context.concurrency_manager.clone(), | ||
)); |
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.
if let Some(txn) = txn { | |
if !txn.is_empty() { | |
modifies.extend(txn.into_modifies()); | |
} | |
} | |
txn = Some(MvccTxn::new( | |
params.start_ts, | |
context.concurrency_manager.clone(), | |
)); | |
if let Some(txn) = txn.replace(MvccTxn::new(...)) { | |
if !txn.is_empty() { | |
modifies.extend(txn.into_modifies()); | |
} | |
} |
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.
replace
is a bit simpler. Same for the reader
below.
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.
Is !txn.is_empty()
necessary? IMO the code will look a bit simpler if removing the if
.
if old_value.resolved() { | ||
let key = key.append_ts(txn.start_ts); | ||
// MutationType is unknown in AcquirePessimisticLock stage. | ||
let mutation_type = None; | ||
old_values.insert(key, (old_value, mutation_type)); | ||
} |
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.
Seems we can extract this common code from acquire_pessimistic_lock, acquire_pessimistic_lock_resumed and prewrite.
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Please fix the conflict. |
I'll fix conflicts after #13777 is merged. |
…med-version-of-pessimistic-lock-command
@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. |
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
/merge |
@MyonKeminta: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger If you have any questions about the PR merge process, please refer to pr process. 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. |
This pull request has been accepted and is ready to merge. Commit hash: d3f0931
|
What is changed and how it works?
Issue Number: Ref #13298
Requires: #13680
What's Changed:
……but I doubt that whether it would be better if I add a new command instead of making
AcquirePessimisticLock
an enum insideRelated changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Side effects
Release note