Jelajahi Sumber

Remove a special case that will never happen.

Jing Yang 4 tahun lalu
induk
melakukan
87cec9b0e0
1 mengubah file dengan 1 tambahan dan 14 penghapusan
  1. 1 14
      src/snapshot.rs

+ 1 - 14
src/snapshot.rs

@@ -118,20 +118,7 @@ impl<C: 'static + Clone + Default + Send + serde::Serialize> Raft<C> {
                     continue;
                 }
 
-                if snapshot.last_included_index >= rf.log.end() {
-                    // We recently rolled back some of the committed logs. This
-                    // can happen but usually the same exact log entries will be
-                    // installed in the next AppendEntries request.
-                    // There is no need to retry, because when the log entries
-                    // are re-committed, we will be notified again.
-
-                    // We will not be notified when the log length changes. Thus
-                    // when the log length grows to passing last_included_index
-                    // the first time, no snapshot will be taken, although
-                    // nothing is preventing it to be done. We will wait until
-                    // at least one more entry is committed.
-                    continue;
-                }
+                assert!(snapshot.last_included_index < rf.log.end());
 
                 rf.log.shift(snapshot.last_included_index, snapshot.data);
                 persister.save_snapshot_and_state(