mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: check and select committed entries to apply
This commit is contained in:
parent
f6a7f96967
commit
dfaa7290c4
@ -360,7 +360,18 @@ func (s *EtcdServer) run() {
|
||||
// care to apply entries in a single goroutine, and not
|
||||
// race them.
|
||||
if len(rd.CommittedEntries) != 0 {
|
||||
appliedi = s.apply(rd.CommittedEntries)
|
||||
firsti := rd.CommittedEntries[0].Index
|
||||
if appliedi == 0 {
|
||||
appliedi = firsti - 1
|
||||
}
|
||||
if firsti > appliedi+1 {
|
||||
log.Panicf("etcdserver: first index of committed entry[%d] should <= appliedi[%d] + 1", firsti, appliedi)
|
||||
}
|
||||
var ents []raftpb.Entry
|
||||
if appliedi+1-firsti < uint64(len(rd.CommittedEntries)) {
|
||||
ents = rd.CommittedEntries[appliedi+1-firsti:]
|
||||
}
|
||||
appliedi = s.apply(ents)
|
||||
}
|
||||
|
||||
s.node.Advance()
|
||||
|
Loading…
x
Reference in New Issue
Block a user