diff --git a/openraft/src/replication/mod.rs b/openraft/src/replication/mod.rs index 7e4fc651a..c020f65cf 100644 --- a/openraft/src/replication/mod.rs +++ b/openraft/src/replication/mod.rs @@ -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; diff --git a/tests/tests/replication/t60_feature_loosen_follower_log_revert.rs b/tests/tests/replication/t60_feature_loosen_follower_log_revert.rs index e5d7e01ff..ab1f8f110 100644 --- a/tests/tests/replication/t60_feature_loosen_follower_log_revert.rs +++ b/tests/tests/replication/t60_feature_loosen_follower_log_revert.rs @@ -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()?,