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: use EpochWithGap::new_max_epoch if the provided epoch is max epoch #13881

Merged
merged 3 commits into from
Dec 10, 2023

Conversation

hzxa21
Copy link
Collaborator

@hzxa21 hzxa21 commented Dec 8, 2023

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

What's changed and what's your intention?

#13696 fixes the max epoch bug for range tombstone but introduces a overflow panic when the provided epoch is u64::MAX. For example, the HummockEpoch::MAX epoch here will be later used to create EpochWithGap with MAX_SPILL_TIMES, which will cause a u64 overflow. This panic will be 100% triggered for sinks with log store enabled.

This PR fixes the issue by treating epochs in [MAX_EPOCH, u64::MAX] as the maximum EpochWithGap(u64::MAX).

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • 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.

Copy link
Contributor

@xxhZs xxhZs left a comment

Choose a reason for hiding this comment

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

Test in the same way , fix this issue #13882

EpochWithGap::new_max_epoch()
} else {
debug_assert!((epoch & EPOCH_SPILL_TIME_MASK) == 0);
EpochWithGap(epoch + spill_offset)
Copy link
Contributor

Choose a reason for hiding this comment

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

expected u64, found u16

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Copy link

codecov bot commented Dec 8, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (51c76aa) 68.22% compared to head (0bdcc88) 68.22%.
Report is 42 commits behind head on main.

Files Patch % Lines
src/storage/hummock_sdk/src/lib.rs 87.50% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13881   +/-   ##
=======================================
  Coverage   68.22%   68.22%           
=======================================
  Files        1525     1525           
  Lines      262188   262189    +1     
=======================================
+ Hits       178867   178878   +11     
+ Misses      83321    83311   -10     
Flag Coverage Δ
rust 68.22% <87.50%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

// Low EPOCH_AVAILABLE_BITS bits set to 1
pub const EPOCH_SPILL_TIME_MASK: u64 = (1 << EPOCH_AVAILABLE_BITS) - 1;
// High (64-EPOCH_AVAILABLE_BITS) bits set to 1
pub const EPOCH_MASK: u64 = !EPOCH_SPILL_TIME_MASK;
Copy link
Contributor

Choose a reason for hiding this comment

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

The EPOCH_MASK is fully flipped compared to before this PR. It is used anywhere else? If not I think we can remove this const or make it private.

Copy link
Contributor

@wcy-fdu wcy-fdu left a comment

Choose a reason for hiding this comment

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

Thanks

@hzxa21 hzxa21 added this pull request to the merge queue Dec 10, 2023
@hzxa21 hzxa21 removed this pull request from the merge queue due to a manual request Dec 10, 2023
@hzxa21 hzxa21 enabled auto-merge December 10, 2023 13:48
@hzxa21 hzxa21 added this pull request to the merge queue Dec 10, 2023
Merged via the queue into main with commit e513e6b Dec 10, 2023
26 of 27 checks passed
@hzxa21 hzxa21 deleted the patrick/fix-max-epoch branch December 10, 2023 14:56
huangjw806 pushed a commit that referenced this pull request Dec 11, 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.

4 participants