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

Move the "LeaderLogShrunk" so that we only check it when we are the leader.

The behavior was originally introduced in d535752305ab3.
Jing Yang 3 éve
szülő
commit
16dbee97f6
1 módosított fájl, 7 hozzáadás és 7 törlés
  1. 7 7
      src/sync_log_entries.rs

+ 7 - 7
src/sync_log_entries.rs

@@ -193,13 +193,6 @@ impl<Command: ReplicableCommand> Raft<Command> {
             Ok(SyncLogEntriesResult::Success) => {
                 let mut rf = rf.lock();
 
-                check_or_record!(
-                    match_index < rf.log.end(),
-                    ErrorKind::LeaderLogShrunk(match_index),
-                    "The leader log shrunk",
-                    &rf
-                );
-
                 if !rf.is_leader() {
                     return;
                 }
@@ -208,6 +201,13 @@ impl<Command: ReplicableCommand> Raft<Command> {
                     return;
                 }
 
+                check_or_record!(
+                    match_index < rf.log.end(),
+                    ErrorKind::LeaderLogShrunk(match_index),
+                    "The leader log shrunk",
+                    &rf
+                );
+
                 rf.next_index[peer_index] = match_index + 1;
                 rf.current_step[peer_index] = 0;
                 if match_index > rf.match_index[peer_index] {