Browse files

Fix read-only query latency for large heartbeat intervals

Read-only queries wait for a round of heartbeats to come back from a
majority of the cluster. They were meant to schedule a round of
heartbeats right away, but the code was missing a broadcast to a
condition variable, causing the read-only queries to wait for the
regularly scheduled heartbeats. This isn't so terrible with the default
heartbeat interval of 75ms, but it's not ok for higher intervals.
  • Loading branch information...
ongardie committed Jan 28, 2015
1 parent a1912fd commit 35b46b51a19c59f2542b8be044199d99a5dca067
Showing with 2 additions and 0 deletions.
  1. +1 −0 Server/
  2. +1 −0 Server/RaftConsensus.h
@@ -2346,6 +2346,7 @@ RaftConsensus::upToDateLeader(std::unique_lock<Mutex>& lockGuard) const
uint64_t epoch = currentEpoch;
// schedule a heartbeat now so that this returns quickly
while (true) {
if (exiting || state != State::LEADER)
return false;
@@ -1302,6 +1302,7 @@ class RaftConsensus {
* - startElectionAt changes (see note under startElectionAt).
* - an acknowledgement from a peer is received.
* - a server goes from not caught up to caught up.
* - a heartbeat is scheduled.
* TODO(ongaro): Should there be multiple condition variables? This one is
* used by a lot of threads for a lot of different conditions.

0 comments on commit 35b46b5

Please sign in to comment.