Merge pull request #10680 from nvanbenschoten/nvanbenschoten/appendAlloc

raft: avoid allocation of Raft entry due to logging
release-3.4
Xiang Li 2019-04-27 18:14:20 -07:00 committed by GitHub
commit efcc1088f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -1005,11 +1005,12 @@ func stepLeader(r *raft, m pb.Message) error {
return ErrProposalDropped
}
for i, e := range m.Entries {
for i := range m.Entries {
e := &m.Entries[i]
if e.Type == pb.EntryConfChange {
if r.pendingConfIndex > r.raftLog.applied {
r.logger.Infof("propose conf %s ignored since pending unapplied configuration [index %d, applied %d]",
e.String(), r.pendingConfIndex, r.raftLog.applied)
e, r.pendingConfIndex, r.raftLog.applied)
m.Entries[i] = pb.Entry{Type: pb.EntryNormal}
} else {
r.pendingConfIndex = r.raftLog.lastIndex() + uint64(i) + 1