Skip to content

Commit

Permalink
chore: temporarily bypass FullKeyTracker for #15099 (#15100)
Browse files Browse the repository at this point in the history
  • Loading branch information
zwang28 authored Feb 17, 2024
1 parent e2c1410 commit dfb7989
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/storage/hummock_sdk/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,14 +935,21 @@ pub fn bound_table_key_range<T: AsRef<[u8]> + EmptySliceRef>(
pub struct FullKeyTracker<T: AsRef<[u8]> + Ord + Eq> {
pub latest_full_key: FullKey<T>,
last_observed_epoch_with_gap: EpochWithGap,
/// TODO: Temporary bypass full key check. Remove this field after #15099 is resolved.
allow_same_full_key: bool,
}

impl<T: AsRef<[u8]> + Ord + Eq> FullKeyTracker<T> {
pub fn new(init_full_key: FullKey<T>) -> Self {
Self::with_config(init_full_key, false)
}

pub fn with_config(init_full_key: FullKey<T>, allow_same_full_key: bool) -> Self {
let epoch_with_gap = init_full_key.epoch_with_gap;
Self {
latest_full_key: init_full_key,
last_observed_epoch_with_gap: epoch_with_gap,
allow_same_full_key,
}
}

Expand Down Expand Up @@ -1032,7 +1039,10 @@ impl<T: AsRef<[u8]> + Ord + Eq> FullKeyTracker<T> {
))
}
Ordering::Equal => {
if max_epoch_with_gap >= self.last_observed_epoch_with_gap {
if max_epoch_with_gap > self.last_observed_epoch_with_gap
|| (!self.allow_same_full_key
&& max_epoch_with_gap == self.last_observed_epoch_with_gap)
{
// Epoch from the same user key should be monotonically decreasing
panic!(
"key {:?} epoch {:?} >= prev epoch {:?}",
Expand Down
6 changes: 3 additions & 3 deletions src/storage/src/hummock/iterator/forward_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<I: HummockIterator<Direction = Forward>> UserIterator<I> {
delete_range_iter,
_version: version,
is_current_pos_valid: false,
full_key_tracker: FullKeyTracker::new(FullKey::default()),
full_key_tracker: FullKeyTracker::with_config(FullKey::default(), true),
}
}

Expand Down Expand Up @@ -136,7 +136,7 @@ impl<I: HummockIterator<Direction = Forward>> UserIterator<I> {
pub async fn rewind(&mut self) -> HummockResult<()> {
// Reset
self.is_current_pos_valid = false;
self.full_key_tracker = FullKeyTracker::new(FullKey::default());
self.full_key_tracker = FullKeyTracker::with_config(FullKey::default(), true);

// Handle range scan
match &self.key_range.0 {
Expand Down Expand Up @@ -180,7 +180,7 @@ impl<I: HummockIterator<Direction = Forward>> UserIterator<I> {
pub async fn seek(&mut self, user_key: UserKey<&[u8]>) -> HummockResult<()> {
// Reset
self.is_current_pos_valid = false;
self.full_key_tracker = FullKeyTracker::new(FullKey::default());
self.full_key_tracker = FullKeyTracker::with_config(FullKey::default(), true);

// Handle range scan when key < begin_key
let user_key = match &self.key_range.0 {
Expand Down

0 comments on commit dfb7989

Please sign in to comment.