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

Clear stale data using DeleteFilesInRanges #2731

Merged
merged 10 commits into from Feb 3, 2018
Merged

Clear stale data using DeleteFilesInRanges #2731

merged 10 commits into from Feb 3, 2018

Conversation

huachaohuang
Copy link
Contributor

Optimize clear_stale_data by deleting files in multiple ranges at once.

for cf in db.cf_names() {
let mut delete_ranges = Vec::new();
for range in ranges {
assert!(range.0 <= range.1);
Copy link
Member

Choose a reason for hiding this comment

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

I think we should skip it when range.start == range.end.

let handle = get_cf_handle(db, cf)?;
db.delete_file_in_range_cf(handle, start_key, &end)?;
db.delete_files_in_ranges_cf(handle, &delete_ranges, /* include_end */ false)?;
Copy link
Member

Choose a reason for hiding this comment

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

Please check if delete_ranges empty before involve delete_files_in_ranges_cf.
BTW, we only need to calculate ranges once and reuse it for each cf.

}

#[test]
fn test_clear_stale_data() {
Copy link
Member

Choose a reason for hiding this comment

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

Can you test it in integration tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to create a fake raft store here, seems I can't do that in integration tests?

Copy link
Member

Choose a reason for hiding this comment

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

There is a raftstore node in integration tests already. You can just new a single node cluster and do whatever you want.

));
pub fn roughly_cleanup_ranges(db: &DB, ranges: &[(Vec<u8>, Vec<u8>)]) -> Result<(), String> {
let mut delete_ranges = Vec::new();
for range in ranges {
Copy link
Member

Choose a reason for hiding this comment

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

Why not use (ref start_key, ref end_key) in ranges?

@BusyJay
Copy link
Member

BusyJay commented Feb 1, 2018

Any updates?

@huachaohuang
Copy link
Contributor Author

Working on the test.

zhangjinpeng87
zhangjinpeng87 previously approved these changes Feb 1, 2018
Copy link
Member

@zhangjinpeng87 zhangjinpeng87 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhangjinpeng87
Copy link
Member

@BusyJay PTAL

@ngaut
Copy link
Member

ngaut commented Feb 1, 2018

/run-all-tests

BusyJay
BusyJay previously approved these changes Feb 1, 2018
@huachaohuang
Copy link
Contributor Author

/run-all-tests

4 similar comments
@huachaohuang
Copy link
Contributor Author

/run-all-tests

@huachaohuang
Copy link
Contributor Author

/run-all-tests

@huachaohuang
Copy link
Contributor Author

/run-all-tests

@huachaohuang
Copy link
Contributor Author

/run-all-tests

@huachaohuang
Copy link
Contributor Author

/run-all-tests

@huachaohuang
Copy link
Contributor Author

/run-all-tests

@huachaohuang
Copy link
Contributor Author

/run-all-tests

@huachaohuang
Copy link
Contributor Author

OMG, all checks have passed, anyone seeing this please approve and merge this for me :)

@huachaohuang huachaohuang merged commit 2f44c62 into tikv:master Feb 3, 2018
@huachaohuang huachaohuang deleted the delete-files branch February 3, 2018 04:53
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants