From dfb7989e30111e8eae26bdb5687130274d96bd4d Mon Sep 17 00:00:00 2001 From: zwang28 <70626450+zwang28@users.noreply.github.com> Date: Sat, 17 Feb 2024 14:55:21 +0800 Subject: [PATCH] chore: temporarily bypass FullKeyTracker for #15099 (#15100) --- src/storage/hummock_sdk/src/key.rs | 12 +++++++++++- src/storage/src/hummock/iterator/forward_user.rs | 6 +++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/storage/hummock_sdk/src/key.rs b/src/storage/hummock_sdk/src/key.rs index e46cc8b65cfc9..0395c58fd10a4 100644 --- a/src/storage/hummock_sdk/src/key.rs +++ b/src/storage/hummock_sdk/src/key.rs @@ -935,14 +935,21 @@ pub fn bound_table_key_range + EmptySliceRef>( pub struct FullKeyTracker + Ord + Eq> { pub latest_full_key: FullKey, 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 + Ord + Eq> FullKeyTracker { pub fn new(init_full_key: FullKey) -> Self { + Self::with_config(init_full_key, false) + } + + pub fn with_config(init_full_key: FullKey, 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, } } @@ -1032,7 +1039,10 @@ impl + Ord + Eq> FullKeyTracker { )) } 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 {:?}", diff --git a/src/storage/src/hummock/iterator/forward_user.rs b/src/storage/src/hummock/iterator/forward_user.rs index f84e0038312bf..f006d041d5540 100644 --- a/src/storage/src/hummock/iterator/forward_user.rs +++ b/src/storage/src/hummock/iterator/forward_user.rs @@ -78,7 +78,7 @@ impl> UserIterator { 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), } } @@ -136,7 +136,7 @@ impl> UserIterator { 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 { @@ -180,7 +180,7 @@ impl> UserIterator { 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 {