alievmirza commented on a change in pull request #481:
URL: https://github.com/apache/ignite-3/pull/481#discussion_r790933676
##########
File path:
modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java
##########
@@ -608,6 +614,48 @@ private void handleElectionTimeout() {
}
}
+ /**
+ * Method that adjusts election timeout after several consecutive
unsuccessful leader elections according to {@link TimeoutStrategy}
+ * <p>
+ * Notes about general algorithm: The main idea is that in a stable
cluster election timeout should be relatively small, but when
+ * something is preventing elections from completion, like an unstable
network or long GC pauses, we don't want to have a lot of
+ * elections, so election timeout is adjusted. Hence, the upper bound of
the election timeout adjusting is the value, which is enough to
+ * elect a leader or handle problems that prevent a successful leader
election.
+ * <p>
+ * Leader election timeout is set to an initial value after a successful
election of a leader.
+ */
+ private void adjustElectionTimeout() {
+ electionRound++;
+
+ if (!electionAdjusted) {
+ initialElectionTimeout = options.getElectionTimeoutMs();
+ }
+
+ long timeout =
options.getElectionTimeoutStrategy().nextTimeout(options.getElectionTimeoutMs(),
electionRound);
+
+ if (timeout != options.getElectionTimeoutMs()) {
+ LOG.info("Election timeout was adjusted according to {} ",
options.getElectionTimeoutStrategy().toString());
+ resetElectionTimeoutMs((int) timeout);
+ electionAdjusted = true;
+ electionRound = 0;
Review comment:
I thought that we could use the logic with several election attempts
without adjusting also after the moment when the timeout was adjusted.
Motivation is to postpone a moment when we reach the maximum election timeout.
Seems, that logic without resetting is more clear, I'll revert this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]