瀏覽代碼

Merge pull request #10680 from nvanbenschoten/nvanbenschoten/appendAlloc

raft: avoid allocation of Raft entry due to logging
Xiang Li 6 年之前
父節點
當前提交
efcc1088f0
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      raft/raft.go

+ 3 - 2
raft/raft.go

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