raft: panic if loaded commit is out of range

This commit is contained in:
Yicheng Qin 2014-12-02 21:58:48 -08:00
parent e07e2ac124
commit 38768e5396

View File

@ -628,6 +628,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