Skip to content

Commit

Permalink
small fix based on testing
Browse files Browse the repository at this point in the history
  • Loading branch information
zach-schoenberger committed Oct 17, 2023
1 parent c53f0ab commit da718dd
Show file tree
Hide file tree
Showing 4 changed files with 2,371 additions and 12 deletions.
13 changes: 9 additions & 4 deletions openraft/src/core/sm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,16 @@ where
}
InstallSnapshotData::Chunk(chunk) => match self.streaming.as_mut() {
Some(streaming) => {
if streaming.receive(chunk).await? {
streaming.manifest.is_complete()
} else {
false
if !streaming.receive(chunk).await? {
// we received a chunk that doesn't exist in the manifest
tracing::warn!(
snapshot_req_id = debug(&req_id),
"{} chunk does not exist in manifest",
func_name!()
);
}

streaming.manifest.is_complete()
}
None => {
tracing::error!("should never happen");
Expand Down
7 changes: 7 additions & 0 deletions openraft/src/raft_state/membership_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod change_handler;
#[cfg(test)] mod membership_state_test;

pub(crate) use change_handler::ChangeHandler;
use tracing::info;

/// The state of membership configs a raft node needs to know.
///
Expand Down Expand Up @@ -85,6 +86,7 @@ where
pub(crate) fn commit(&mut self, committed_log_id: &Option<LogId<NID>>) {
if committed_log_id >= self.effective().log_id() {
debug_assert!(committed_log_id.index() >= self.effective().log_id().index());
info!("committed: {:?} effective: {:?}", self.committed, self.effective);
self.committed = self.effective.clone();
}
}
Expand Down Expand Up @@ -123,6 +125,7 @@ where
}

if c.log_id() > self.committed.log_id() {
info!("c.log_id: {:?} committed: {:?}", c.log_id(), self.committed.log_id());
self.committed = c
}

Expand Down Expand Up @@ -151,6 +154,10 @@ where

// Openraft allows at most only one non-committed membership config.
// If there is another new config, self.effective must have been committed.
info!(
"append: committed: {:?} effective: {:?}",
self.committed, self.effective
);
self.committed = self.effective.clone();
self.effective = m;
}
Expand Down
Loading

0 comments on commit da718dd

Please sign in to comment.