Skip to content

Commit b49974d

Browse files
committed
RATIS-707. Test failures caused by minTimeout set to zero. Contributed by Siddharth Wagle
1 parent 3f446aa commit b49974d

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import java.util.concurrent.ExecutionException;
5151
import java.util.concurrent.ThreadLocalRandom;
5252
import java.util.concurrent.TimeUnit;
53-
import java.util.concurrent.atomic.AtomicBoolean;
5453
import java.util.concurrent.atomic.AtomicReference;
5554
import java.util.function.Function;
5655
import java.util.function.Supplier;
@@ -97,8 +96,6 @@ public class RaftServerImpl implements RaftServerProtocol, RaftServerAsynchronou
9796

9897
private AtomicReference<TermIndex> inProgressInstallSnapshotRequest;
9998

100-
private final AtomicBoolean honorMinTimeoutMs = new AtomicBoolean();
101-
10299
RaftServerImpl(RaftGroup group, StateMachine stateMachine, RaftServerProxy proxy) throws IOException {
103100
final RaftPeerId id = proxy.getId();
104101
LOG.info("{}: new RaftServerImpl for {} with {}", id, group, stateMachine);
@@ -151,12 +148,7 @@ int getMaxTimeoutMs() {
151148
}
152149

153150
int getRandomTimeoutMs() {
154-
return (honorMinTimeoutMs.get() ? minTimeoutMs : 0) +
155-
ThreadLocalRandom.current().nextInt(maxTimeoutMs - minTimeoutMs + 1);
156-
}
157-
158-
void honorMinTimeoutMs() {
159-
honorMinTimeoutMs.set(Boolean.TRUE);
151+
return minTimeoutMs + ThreadLocalRandom.current().nextInt(maxTimeoutMs - minTimeoutMs + 1);
160152
}
161153

162154
int getSleepDeviationThresholdMs() {

ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ void setLeader(RaftPeerId newLeaderId, String op) {
251251
lastNoLeaderTime = null;
252252
suffix = ", leader elected after " + previous.elapsedTimeMs() + "ms";
253253
server.getStateMachine().notifyLeaderChanged(getMemberId(), newLeaderId);
254-
server.honorMinTimeoutMs();
255254
}
256255
LOG.info("{}: change Leader from {} to {} at term {} for {}{}",
257256
getMemberId(), leaderId, newLeaderId, getCurrentTerm(), op, suffix);

0 commit comments

Comments
 (0)