mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: fix memoryStorage append
This commit is contained in:
parent
2876c652ab
commit
10ebf1a335
@ -81,7 +81,7 @@ func (l *raftLog) maybeAppend(index, logTerm, committed uint64, ents ...pb.Entry
|
||||
switch {
|
||||
case ci == 0:
|
||||
case ci <= l.committed:
|
||||
panic("conflict with committed entry")
|
||||
log.Panicf("conflict(%d) with committed entry [committed(%d)]", ci, l.committed)
|
||||
default:
|
||||
l.append(ci-1, ents[ci-from:]...)
|
||||
}
|
||||
|
@ -176,5 +176,12 @@ func (ms *MemoryStorage) Compact(i uint64, cs *pb.ConfState, data []byte) error
|
||||
func (ms *MemoryStorage) Append(entries []pb.Entry) {
|
||||
ms.Lock()
|
||||
defer ms.Unlock()
|
||||
if len(entries) == 0 {
|
||||
return
|
||||
}
|
||||
offset := entries[0].Index - ms.snapshot.Metadata.Index
|
||||
if uint64(len(ms.ents)) >= offset {
|
||||
ms.ents = ms.ents[:offset]
|
||||
}
|
||||
ms.ents = append(ms.ents, entries...)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user