Merge pull request #165 from philips/add-comment-on-nop-command

docs(server): add a comment explaining the NOPCommand
pull/820/head
Xiang Li 2014-01-23 13:07:08 -08:00
commit 0a20921dcb
1 changed files with 4 additions and 0 deletions

View File

@ -763,6 +763,10 @@ func (s *server) leaderLoop() {
peer.startHeartbeat()
}
// Commit a NOP after the server becomes leader. From the Raft paper:
// "Upon election: send initial empty AppendEntries RPCs (heartbeat) to
// each server; repeat during idle periods to prevent election timeouts
// (§5.2)". The heartbeats started above do the "idle" period work.
go s.Do(NOPCommand{})
// Begin to collect response from followers