Skip to content

Commit

Permalink
fix try_wait_epoch assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
zwang28 committed Jan 5, 2023
1 parent 6f21a92 commit 2966432
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/storage/src/hummock/state_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,21 @@ impl StateStore for HummockStorage {

define_state_store_associated_type!();

/// Waits until the local hummock version contains the epoch. If `wait_epoch` is `Current`,
/// we will only check whether it is le `sealed_epoch` and won't wait.
/// Waits until the local hummock version contains the epoch.
fn try_wait_epoch(&self, wait_epoch: HummockReadEpoch) -> Self::WaitEpochFuture<'_> {
async move {
// Ok(self.local_version_manager.try_wait_epoch(epoch).await?)
let wait_epoch = match wait_epoch {
HummockReadEpoch::Committed(epoch) => epoch,
HummockReadEpoch::Current(epoch) => {
// let sealed_epoch = self.local_version.read().get_sealed_epoch();
// Check whether `epoch` is less than `sealed_epoch`.
let sealed_epoch = (*self.seal_epoch).load(MemOrdering::SeqCst);
assert!(
epoch <= sealed_epoch
&& epoch != HummockEpoch::MAX
,
"current epoch can't read, because the epoch in storage is not updated, epoch{}, sealed epoch{}"
,epoch
,sealed_epoch
);
return Ok(());
if epoch <= sealed_epoch {
return Ok(());
}
// If not, wait until `epoch` <= MCE.
// FIXME: `epoch` <= MCE is too conservative, as `epoch` <= `seal_epoch` is enough.
tracing::warn!("current epoch can't read, because the epoch in storage is not updated, epoch{}, sealed epoch{}", epoch, sealed_epoch);
epoch
}
HummockReadEpoch::NoWait(_) | HummockReadEpoch::Backup(_) => return Ok(()),
};
Expand Down

0 comments on commit 2966432

Please sign in to comment.