소스 검색

Do not update next_index if it is not our term.

Jing Yang 5 년 전
부모
커밋
9833aaf196
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      src/lib.rs

+ 5 - 0
src/lib.rs

@@ -660,6 +660,11 @@ impl Raft {
         match succeeded {
             Ok(Some(true)) => {
                 let mut rf = rf.lock();
+
+                if rf.current_term != term {
+                    return;
+                }
+
                 rf.next_index[peer_index] = match_index + 1;
                 rf.current_step[peer_index] = 0;
                 if match_index > rf.match_index[peer_index] {