Skip to content

Commit

Permalink
Fix: defensive_no_dirty_log hangs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YangKian committed Jan 7, 2022
1 parent 305abb3 commit 5a02667
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions openraft/src/defensive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ where

let (last_applied, _) = self.inner().last_applied_state().await?;
let (_, last) = self.inner().get_log_state().await?;
let last_log_id = last.expect("last_log_id should not be None.");

if last_log_id.index > last_applied.index && last_log_id < last_applied {
return Err(
DefensiveError::new(ErrorSubject::Log(last_log_id), Violation::DirtyLog {
higher_index_log_id: last_log_id,
lower_index_log_id: last_applied,
})
.into(),
);
if let Some(last_log_id) = last {
if last_log_id.index > last_applied.index && last_log_id < last_applied {
return Err(
DefensiveError::new(ErrorSubject::Log(last_log_id), Violation::DirtyLog {
higher_index_log_id: last_log_id,
lower_index_log_id: last_applied,
})
.into(),
);
}
}

Ok(())
Expand Down

0 comments on commit 5a02667

Please sign in to comment.