Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
cherrypick-2.0: etcd-io/etcd#9778
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Jun 27, 2018
1 parent a3a3a85 commit 21a4bef
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions github.com/coreos/etcd/raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,19 +693,13 @@ func (r *raft) becomeLeader() {
r.tick = r.tickHeartbeat
r.lead = r.id
r.state = StateLeader
ents, err := r.raftLog.entries(r.raftLog.committed+1, noLimit)
if err != nil {
r.logger.Panicf("unexpected error getting uncommitted entries (%v)", err)
}

// Conservatively set the pendingConfIndex to the last index in the
// log. There may or may not be a pending config change, but it's
// safe to delay any future proposals until we commit all our
// pending log entries, and scanning the entire tail of the log
// could be expensive.
if len(ents) > 0 {
r.pendingConfIndex = ents[len(ents)-1].Index
}
r.pendingConfIndex = r.raftLog.lastIndex()

r.appendEntry(pb.Entry{Data: nil})
r.logger.Infof("%x became leader at term %d", r.id, r.Term)
Expand Down

0 comments on commit 21a4bef

Please sign in to comment.