mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: not compact log if the compact index < first index of the log
It should ignore the compact operation instead of panic because the case that the log is restored from snapshot before executing compact is reasonable.
This commit is contained in:
parent
1a5333e51d
commit
4b43824be9
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user