瀏覽代碼

Merge pull request #1716 from yichengq/225

raft: panic if loaded commit is out of range
Yicheng Qin 11 年之前
父節點
當前提交
23b32a6cbe
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      raft/raft.go

+ 3 - 0
raft/raft.go

@@ -635,6 +635,9 @@ func (r *raft) promotable() bool {
 }
 
 func (r *raft) loadState(state pb.HardState) {
+	if state.Commit < r.raftLog.committed || state.Commit > r.raftLog.lastIndex() {
+		log.Panicf("raft: %x state.commit %d is out of range [%d, %d]", r.id, state.Commit, r.raftLog.committed, r.raftLog.lastIndex())
+	}
 	r.raftLog.committed = state.Commit
 	r.Term = state.Term
 	r.Vote = state.Vote