Skip to content

Commit

Permalink
Fix read-only query latency for large heartbeat intervals
Browse files Browse the repository at this point in the history
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 35b46b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions Server/RaftConsensus.cc
Expand Up @@ -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
configuration->forEach(&Server::scheduleHeartbeat);
stateChanged.notify_all();
while (true) {
if (exiting || state != State::LEADER)
return false;
Expand Down
1 change: 1 addition & 0 deletions Server/RaftConsensus.h
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 35b46b5

Please sign in to comment.