瀏覽代碼

Merge pull request #1784 from yichengq/234

raft: not compact log if the compact index < first index of the log
Yicheng Qin 11 年之前
父節點
當前提交
dd57c1f189
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      raft/raft.go

+ 4 - 0
raft/raft.go

@@ -534,6 +534,10 @@ func (r *raft) compact(index uint64, nodes []uint64, d []byte) {
 	if index > r.raftLog.applied {
 		panic(fmt.Sprintf("raft: compact index (%d) exceeds applied index (%d)", index, r.raftLog.applied))
 	}
+	if index < r.raftLog.offset {
+		//TODO: return an error?
+		return
+	}
 	r.raftLog.snap(d, index, r.raftLog.term(index), nodes)
 	r.raftLog.compact(index)
 }