From 0771d713e6a2cafaa0546e01c1e39afec67212c3 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Tue, 26 Jan 2016 16:55:47 -0500 Subject: [PATCH] raft: Always call bcastAppend after maybeCommit --- raft/raft.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/raft/raft.go b/raft/raft.go index 23397dce1..28b36960a 100644 --- a/raft/raft.go +++ b/raft/raft.go @@ -360,6 +360,9 @@ func (r *raft) bcastHeartbeat() { } } +// maybeCommit attempts to advance the commit index. Returns true if +// the commit index changed (in which case the caller should call +// r.bcastAppend). func (r *raft) maybeCommit() bool { // TODO(bmizerany): optimize.. Currently naive mis := make(uint64Slice, 0, len(r.prs)) @@ -399,6 +402,7 @@ func (r *raft) appendEntry(es ...pb.Entry) { } r.raftLog.append(es...) r.prs[r.id].maybeUpdate(r.raftLog.lastIndex()) + // Regardless of maybeCommit's return, our caller will call bcastAppend. r.maybeCommit() } @@ -828,7 +832,9 @@ func (r *raft) removeNode(id uint64) { r.pendingConf = false // The quorum size is now smaller, so see if any pending entries can // be committed. - r.maybeCommit() + if r.maybeCommit() { + r.bcastAppend() + } } func (r *raft) resetPendingConf() { r.pendingConf = false }