Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #200: update leader timeouts after disk write #201

Merged
merged 1 commit into from
Feb 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
issue #200: update leader timeouts after disk write
in cases where disk writes can take longer than the leader election,
a follower can call for an election when one is not necessary. this
change resets the election related timers after all disk writes.
  • Loading branch information
Nate Hardt committed Dec 7, 2015
commit 745f2bba7158cbdd8ee2f148bd12f58353bed3a9
4 changes: 4 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ See [RELEASE-PROCESS.md](RELEASE-PROCESS.md).
Version 1.2.0-alpha.0 (In Development)
======================================

Internal improvements:

- #200: reset leader election timeout in follower after disk io completes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an improvement, not a bug fix :)


New backwards-compatible changes:

- Added new API getConfiguration2, which behaves as getConfiguration
Expand Down
12 changes: 10 additions & 2 deletions Server/RaftConsensus.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Copyright (c) 2012 Stanford University
* Copyright (c) 2015 Diego Ongaro
* Copyright (c) 2015 Scale Computing
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand Down Expand Up @@ -1298,8 +1299,10 @@ RaftConsensus::handleAppendEntries(
// 'response' accordingly.
response.set_term(request.term());
}
// This request is a sign of life from the current leader. Update our term
// and convert to follower if necessary; reset the election timer.
// This request is a sign of life from the current leader. Update
// our term and convert to follower if necessary; reset the
// election timer. set it here in case request we exit the
// function early, we will set it again after the disk write.
stepDown(request.term());
setElectionTimer();
withholdVotesUntil = Clock::now() + ELECTION_TIMEOUT;
Expand Down Expand Up @@ -1416,6 +1419,11 @@ RaftConsensus::handleAppendEntries(
stateChanged.notify_all();
VERBOSE("New commitIndex: %lu", commitIndex);
}

// reset election timer to avoid punishing the leader for our own
// long disk writes
setElectionTimer();
withholdVotesUntil = Clock::now() + ELECTION_TIMEOUT;
}

void
Expand Down