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

gc_worker: make unsafe detroy range compatible with multi-rocks db #13485

Merged
merged 11 commits into from Sep 20, 2022

Conversation

SpadeA-Tang
Copy link
Member

@SpadeA-Tang SpadeA-Tang commented Sep 19, 2022

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

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test

Release note

None

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>
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>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 19, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • MyonKeminta
  • tonyxuqqi

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.

} 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)?;
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion.

let count = regions.len();

let mut region_modifies = HashMap::default();
for i in 0..count {
Copy link
Contributor

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()

Copy link
Member Author

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(
Copy link
Contributor

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?

Copy link
Member

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.

SpadeA-Tang and others added 3 commits September 19, 2022 12:59
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
@ti-chi-bot ti-chi-bot added size/XL and removed size/L labels Sep 19, 2022
// 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() {
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fine.

@ti-chi-bot ti-chi-bot added the status/LGT1 Status: PR - There is already 1 approval label Sep 19, 2022
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
@ti-chi-bot ti-chi-bot added status/LGT2 Status: PR - There are already 2 approvals and removed status/LGT1 Status: PR - There is already 1 approval labels Sep 20, 2022
@MyonKeminta
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

@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 /merge once, and 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.

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.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: bba951a

@ti-chi-bot ti-chi-bot added the status/can-merge Status: Can merge to base branch label Sep 20, 2022
@ti-chi-bot
Copy link
Member

@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.

@ti-chi-bot ti-chi-bot merged commit 2e11398 into tikv:master Sep 20, 2022
@ti-chi-bot ti-chi-bot added this to the Pool milestone Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution Type: PR - From contributors release-note-none size/XL status/can-merge Status: Can merge to base branch status/LGT2 Status: PR - There are already 2 approvals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make GC compatible with Multi-Rocks DB
5 participants