Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle timers better in the raft machine
The election timer now takes the actual time of the last renewal into account when deciding on whether the timeout in fact has elapsed since the last renewing event. This would otherwise cause undesired behaviour when an election timeout event is scheduled behind events in the message queue which renew the timer but fail to prevent any already scheduled event. The high level symptom is unnecessary leader re-elections. The timer service is a little bit badly designed, but this is a reasonable workaround. The timers are now also not started until the recovery of core state is complete, since the raft message queue is blocked during this time, creating one of the possible situations in which the above described queueing can happen on startup. For the sake of the tests, the controlled timer service is injected with a fake clock which always moves forward by the amount of the invoked timer so that the election timeout in fact spawns an event as an effect of the invocation. The alternative would have been to control the fake clock in every test. The timer code is also cleaned up a bit and not even started in case we are in follower-only mode, since the timers are only useful for candidates and leaders.
- Loading branch information
1 parent
bb5caed
commit 6522323
Showing
10 changed files
with
215 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.