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

fix(storage): handle delete range in same epoch as write #12651

Closed
wants to merge 2 commits into from

Conversation

wenym1
Copy link
Contributor

@wenym1 wenym1 commented Oct 7, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Fix #12650

Currently in the code of compaction runner and imm merge, we introduce an assumption that iter_key.epoch < del_iter.earliest_delete_since(iter_key.epoch) in a debug_assert. However, del_iter.earliest_delete_since(iter_key.epoch) returns an epoch that is >= iter_key.epoch. Therefore, the debug_assert depends on the assumption that the == case will never happen, which means that delete range will not delete a key written in the same epoch. However, in log store, we will write the log item to storage when the buffer is full, and after the log item is consumed by the sink, it will truncate the log with a range delete, and both operation happen in the same epoch, which breaks the assumption.

In this PR, we change our code to handle the case when the epoch of iter key is the same as the delete range. Previous when iter_key.epoch < del_iter.earliest_delete_since(iter_key.epoch), it writes an extra delete in the epoch of the range delete. In this PR, in the new case that iter_key.epoch == del_iter.earliest_delete_since(iter_key.epoch), we turn the insert to HummockValue::Delete anyway.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@github-actions github-actions bot added the type/fix Bug fix label Oct 7, 2023
@codecov
Copy link

codecov bot commented Oct 7, 2023

Codecov Report

Merging #12651 (02342d6) into main (e53c9f7) will decrease coverage by 0.01%.
Report is 10 commits behind head on main.
The diff coverage is 44.82%.

@@            Coverage Diff             @@
##             main   #12651      +/-   ##
==========================================
- Coverage   69.27%   69.26%   -0.01%     
==========================================
  Files        1470     1470              
  Lines      241305   241297       -8     
==========================================
- Hits       167162   167143      -19     
- Misses      74143    74154      +11     
Flag Coverage Δ
rust 69.26% <44.82%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/storage/src/hummock/sstable/block.rs 97.00% <0.00%> (+1.01%) ⬆️
...age/src/hummock/compactor/shared_buffer_compact.rs 85.35% <85.71%> (-0.44%) ⬇️
.../storage/src/hummock/compactor/compactor_runner.rs 79.89% <7.14%> (+0.40%) ⬆️

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@StrikeW StrikeW self-requested a review October 7, 2023 07:08
Copy link
Collaborator

@hzxa21 hzxa21 left a comment

Choose a reason for hiding this comment

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

Generally LGM. @Little-Wallace PTAL

} else {
// If the range delete comes from the same epoch, convert value to Delete anyway.
debug_assert_eq!(iter_key.epoch, earliest_range_delete_which_can_see_iter_key);
value = HummockValue::Delete;
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: should we follow the logic in L780-790 to update last_table_stats as well?

@Little-Wallace
Copy link
Contributor

I do not understand.
According to my understanding, If a delete-rand and put key write in the same barrier, this put key shall be filtered.

@Little-Wallace
Copy link
Contributor

Why log store can not filter put-key just like hummock::utils::filter_with_delete_range?

@Little-Wallace
Copy link
Contributor

It is dangerous to keep the same version of put-key with overlapped delete-range in one sstable. Because all our design is based on there will be no key overlap with delete-ranges in the same file.

@wenym1
Copy link
Contributor Author

wenym1 commented Oct 9, 2023

After offline discussion, we decide to change to truncate the current epoch in the next epoch to avoid doing range delete on a key written in the same epoch.

@wenym1 wenym1 closed this Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sink decouple panics
3 participants