Skip to content

Commit

Permalink
Merge pull request #937 from drmingdrmer/33-fix
Browse files Browse the repository at this point in the history
Fix: avoid panic with "loosen-follower-log-revert" enabled
  • Loading branch information
drmingdrmer authored Nov 17, 2023
2 parents 7382fb1 + 5f26219 commit 7d469c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion openraft/src/replication/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,22 @@ where
func_name!()
);

debug_assert!(self.matching <= new_matching);
if cfg!(feature = "loosen-follower-log-revert") {
if self.matching > new_matching {
tracing::warn!(
"follower log is reverted from {} to {}; with 'loosen-follower-log-revert' enabled, this is allowed",
self.matching.display(),
new_matching.display(),
);
}
} else {
debug_assert!(
self.matching <= new_matching,
"follower log is reverted from {} to {}",
self.matching.display(),
new_matching.display(),
);
}

self.matching = new_matching;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ async fn feature_loosen_follower_log_revert() -> Result<()> {
Config {
enable_tick: false,
enable_heartbeat: false,
// Make sure the replication is done in more than one steps
max_payload_entries: 1,
..Default::default()
}
.validate()?,
Expand Down

0 comments on commit 7d469c3

Please sign in to comment.