Forráskód Böngészése

Add an assertion that helps explain some errors.

Jing Yang 4 éve
szülő
commit
6fd57c9352
1 módosított fájl, 4 hozzáadás és 0 törlés
  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()),