From 754392ff015903cdc1d6d25478623808d68149fc Mon Sep 17 00:00:00 2001 From: Hoverbear Date: Tue, 31 Jul 2018 07:53:43 -0700 Subject: [PATCH] raft: No longer scan raft log when becoming a lead. Ref: https://github.com/coreos/etcd/pull/9887 --- src/raft.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/raft.rs b/src/raft.rs index 2464400f4..d3674f9f2 100644 --- a/src/raft.rs +++ b/src/raft.rs @@ -934,16 +934,12 @@ impl Raft { 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);