Browse Source

raft: Ignore redundant addNode calls.

This avoids clobbering any state when bootstrapping entries are
applied twice.
Ben Darnell 11 years ago
parent
commit
ea4d645a83
1 changed files with 6 additions and 0 deletions
  1. 6 0
      raft/raft.go

+ 6 - 0
raft/raft.go

@@ -472,6 +472,12 @@ func (r *raft) handleSnapshot(m pb.Message) {
 func (r *raft) resetPendingConf() { r.pendingConf = false }
 
 func (r *raft) addNode(id uint64) {
+	if _, ok := r.prs[id]; ok {
+		// Ignore any redundant addNode calls (which can happen because the
+		// initial bootstrapping entries are applied twice).
+		return
+	}
+
 	r.setProgress(id, 0, r.raftLog.lastIndex()+1)
 	r.pendingConf = false
 }