Explorar o código

Add an assertion that helps explain some errors.

Jing Yang %!s(int64=4) %!d(string=hai) anos
pai
achega
6fd57c9352
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      src/process_install_snapshot.rs

+ 4 - 0
src/process_install_snapshot.rs

@@ -45,6 +45,10 @@ impl<C: Clone + Default + serde::Serialize> Raft<C> {
         // to rollback beyond that, since it is guaranteed that committed log
         // entries will never be rolled back.
         if args.last_included_index < rf.log.start() {
+            // This is a condition that should always hold. Combine the if- and
+            // assert- conditions, we can conclude that last_include_index is
+            // smaller than commit_index. The leader might double check that.
+            assert!(rf.log.start() <= rf.commit_index);
             return InstallSnapshotReply {
                 term: args.term,
                 committed: Some(rf.log.first_after(rf.commit_index).into()),