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
gc_worker: make unsafe detroy range compatible with multi-rocks db #13485
Conversation
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
[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. |
src/server/gc_worker/gc_worker.rs
Outdated
} else { | ||
let cfs = &[CF_LOCK, CF_DEFAULT, CF_WRITE]; | ||
let keys = vec![start_key.clone(), end_key.clone()]; | ||
let regions = get_regions_for_gc(self.store_id, &keys, regions_provider)?; |
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.
Does this return all regions covered by the range?
It seems to me that get_regions_for_gc
is only responsible for returning regions that contains one of the keys in the parameter keys
. Otherwise the function get_regions_for_gc
is better to be changed to something like get_regions_in_range
.
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.
Generally, it is. But sometimes keys may only contain one key, so in this case, it is not appropriate to call range?
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.
It can be considered as a range [key
, key.append(0)
) where key is in raw format, thus there is at most one key in the range.
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.
So,just rename the method? Or I should change the keys to Range
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.
Maybe you can rename it to something like get_regions_for_range_of_keys
without changing the parameter it accepts. And explain in comments that the function is used to find all regions in the range inferred by a list of sorted keys.
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.
Thanks for the suggestion.
src/server/gc_worker/gc_worker.rs
Outdated
let count = regions.len(); | ||
|
||
let mut region_modifies = HashMap::default(); | ||
for i in 0..count { |
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.
consider: for (i, region) in regions.into_iter().enumerate()
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.
Good suggestion.
|
||
let mut modifies = Vec::new(); | ||
for cf in cfs { | ||
modifies.push(Modify::DeleteRange( |
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.
cc @BusyJay
Is it possible to delete large ranges in a safe way (instead of bypassing raft) after supporting multi-rocks?
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.
Yes, just send them like normal commands.
// to do it in somewhere of the same layer with apply_worker. | ||
let start_data_key = keys::data_key(start_key.as_encoded()); | ||
let end_data_key = keys::data_end_key(end_key.as_encoded()); | ||
if let Some(local_storage) = self.engine.kv_engine() { |
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.
please add comment this branch is for single rocksdb case.
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.
Fine.
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
/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: bba951a
|
@SpadeA-Tang: 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 is changed and how it works?
Issue Number: Close #13406
What's Changed:
This PR makes unsafe-destroy-range compatible with multi-rocks db.
Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Release note