Skip to content

Commit

Permalink
raft: No longer scan raft log when becoming a lead.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoverbear committed Jul 31, 2018
1 parent 22f038e commit bbeab2e
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,16 +934,7 @@ impl<T: Storage> Raft<T> {
self.reset(term);
self.leader_id = self.id;
self.state = StateRole::Leader;
let begin = self.raft_log.committed + 1;
let ents = self.raft_log
.entries(begin, raft_log::NO_LIMIT)
.expect("unexpected error getting uncommitted entries");
// Conservatively set the pending_conf_index 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.
self.pending_conf_index = ents.last().map_or(0, |e| e.get_index());
self.pending_conf_index = self.raft_log.last_index();

self.append_entry(&mut [Entry::new()]);
info!("{} became leader at term {}", self.tag, self.term);
Expand Down

0 comments on commit bbeab2e

Please sign in to comment.