Skip to content

Commit 00a8a1d

Browse files
committed
RATIS-2233. make NOPROGRESS timeout configurable (#1204)
1 parent 9f56eb7 commit 00a8a1d

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

ratis-docs/src/site/markdown/configurations.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ When bootstrapping a new peer, If the gap between the match index of the
104104
peer and the leader's latest committed index is less than this gap, we
105105
treat the peer as caught-up. Increase this number when write throughput is high.
106106

107+
---------------------------------------------------------------------------------
108+
| **Property** | `raft.server.staging.timeout` |
109+
|:----------------|:-----------------------------------------|
110+
| **Description** | timeout of bootstrapping a new peer |
111+
| **Type** | TimeDuration |
112+
| **Default** | 3 times of `raft.server.rpc.timeout.max` |
113+
114+
During the initialization of a new peer, the leader will classify the bootstrap process as "NO PROGRESS"
115+
if it fails to receive any RPC responses from this peer within this specified timeout period.
116+
107117
---------------------------------------------------------------------------------
108118
### ThreadPool - Configurations related to server thread pools.
109119

ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ static void setStagingCatchupGap(RaftProperties properties, int stagingCatchupGa
116116
setInt(properties::setInt, STAGING_CATCHUP_GAP_KEY, stagingCatchupGap);
117117
}
118118

119+
String STAGING_TIMEOUT_KEY = PREFIX + ".staging.timeout";
120+
121+
TimeDuration STAGING_TIMEOUT_DEFAULT = null;
122+
123+
static TimeDuration stagingTimeout(RaftProperties properties) {
124+
final TimeDuration fallbackStagingTimeout = Rpc.timeoutMax(properties, null).multiply(3);
125+
return getTimeDuration(properties.getTimeDuration(fallbackStagingTimeout.getUnit()),
126+
STAGING_TIMEOUT_KEY, STAGING_TIMEOUT_DEFAULT,
127+
Rpc.TIMEOUT_MAX_KEY, fallbackStagingTimeout, getDefaultLog());
128+
}
129+
static void setStagingTimeout(RaftProperties properties, TimeDuration stagingTimeout) {
130+
setTimeDuration(properties::setTimeDuration, STAGING_TIMEOUT_KEY, stagingTimeout);
131+
}
132+
133+
119134
interface ThreadPool {
120135
String PREFIX = RaftServerConfigKeys.PREFIX + ".threadpool";
121136

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ boolean isApplied() {
350350

351351
private final boolean logMetadataEnabled;
352352
private final int stagingCatchupGap;
353+
private final TimeDuration stagingTimeout;
353354
private final RaftServerMetricsImpl raftServerMetrics;
354355
private final LogAppenderMetrics logAppenderMetrics;
355356
private final long followerMaxGapThreshold;
@@ -364,6 +365,7 @@ boolean isApplied() {
364365

365366
final RaftProperties properties = server.getRaftServer().getProperties();
366367
stagingCatchupGap = RaftServerConfigKeys.stagingCatchupGap(properties);
368+
stagingTimeout = RaftServerConfigKeys.stagingTimeout(properties);
367369

368370
final ServerState state = server.getState();
369371
this.raftLog = state.getLog();
@@ -789,7 +791,7 @@ public void run() {
789791
private BootStrapProgress checkProgress(FollowerInfo follower, long committed) {
790792
Preconditions.assertTrue(!isCaughtUp(follower));
791793
final Timestamp progressTime = Timestamp.currentTime().addTimeMs(-server.getMaxTimeoutMs());
792-
final Timestamp timeoutTime = Timestamp.currentTime().addTimeMs(-3L * server.getMaxTimeoutMs());
794+
final Timestamp timeoutTime = Timestamp.currentTime().addTimeMs(-stagingTimeout.toLong(TimeUnit.MILLISECONDS));
793795
if (follower.getLastRpcResponseTime().compareTo(timeoutTime) < 0) {
794796
LOG.debug("{} detects a follower {} timeout ({}ms) for bootstrapping", this, follower,
795797
follower.getLastRpcResponseTime().elapsedTimeMs());

0 commit comments

Comments
 (0)