This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 5e6cc9de3 RATIS-2233. make NOPROGRESS timeout configurable (#1204)
5e6cc9de3 is described below
commit 5e6cc9de3fd10c4435839035087cd9d13f4b254d
Author: William Song <[email protected]>
AuthorDate: Sat Jan 4 01:58:36 2025 +0800
RATIS-2233. make NOPROGRESS timeout configurable (#1204)
---
ratis-docs/src/site/markdown/configurations.md | 10 ++++++++++
.../org/apache/ratis/server/RaftServerConfigKeys.java | 15 +++++++++++++++
.../org/apache/ratis/server/impl/LeaderStateImpl.java | 4 +++-
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/ratis-docs/src/site/markdown/configurations.md
b/ratis-docs/src/site/markdown/configurations.md
index 71eae7d3d..4caf11b30 100644
--- a/ratis-docs/src/site/markdown/configurations.md
+++ b/ratis-docs/src/site/markdown/configurations.md
@@ -104,6 +104,16 @@ When bootstrapping a new peer, If the gap between the
match index of the
peer and the leader's latest committed index is less than this gap, we
treat the peer as caught-up. Increase this number when write throughput is
high.
+---------------------------------------------------------------------------------
+| **Property** | `raft.server.staging.timeout` |
+|:----------------|:-----------------------------------------|
+| **Description** | timeout of bootstrapping a new peer |
+| **Type** | TimeDuration |
+| **Default** | 3 times of `raft.server.rpc.timeout.max` |
+
+During the initialization of a new peer, the leader will classify the
bootstrap process as "NO PROGRESS"
+if it fails to receive any RPC responses from this peer within this specified
timeout period.
+
---------------------------------------------------------------------------------
### ThreadPool - Configurations related to server thread pools.
diff --git
a/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
index 8e1d92b75..849597433 100644
---
a/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
+++
b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
@@ -116,6 +116,21 @@ public interface RaftServerConfigKeys {
setInt(properties::setInt, STAGING_CATCHUP_GAP_KEY, stagingCatchupGap);
}
+ String STAGING_TIMEOUT_KEY = PREFIX + ".staging.timeout";
+
+ TimeDuration STAGING_TIMEOUT_DEFAULT = null;
+
+ static TimeDuration stagingTimeout(RaftProperties properties) {
+ final TimeDuration fallbackStagingTimeout = Rpc.timeoutMax(properties,
null).multiply(3);
+ return
getTimeDuration(properties.getTimeDuration(fallbackStagingTimeout.getUnit()),
+ STAGING_TIMEOUT_KEY, STAGING_TIMEOUT_DEFAULT,
+ Rpc.TIMEOUT_MAX_KEY, fallbackStagingTimeout, getDefaultLog());
+ }
+ static void setStagingTimeout(RaftProperties properties, TimeDuration
stagingTimeout) {
+ setTimeDuration(properties::setTimeDuration, STAGING_TIMEOUT_KEY,
stagingTimeout);
+ }
+
+
interface ThreadPool {
String PREFIX = RaftServerConfigKeys.PREFIX + ".threadpool";
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java
b/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java
index 5c472c826..f5682e35f 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java
@@ -351,6 +351,7 @@ class LeaderStateImpl implements LeaderState {
private final boolean logMetadataEnabled;
private final int stagingCatchupGap;
+ private final TimeDuration stagingTimeout;
private final RaftServerMetricsImpl raftServerMetrics;
private final LogAppenderMetrics logAppenderMetrics;
private final long followerMaxGapThreshold;
@@ -365,6 +366,7 @@ class LeaderStateImpl implements LeaderState {
final RaftProperties properties = server.getRaftServer().getProperties();
stagingCatchupGap = RaftServerConfigKeys.stagingCatchupGap(properties);
+ stagingTimeout = RaftServerConfigKeys.stagingTimeout(properties);
final ServerState state = server.getState();
this.raftLog = state.getLog();
@@ -791,7 +793,7 @@ class LeaderStateImpl implements LeaderState {
private BootStrapProgress checkProgress(FollowerInfo follower, long
committed) {
Preconditions.assertTrue(!isCaughtUp(follower));
final Timestamp progressTime =
Timestamp.currentTime().addTimeMs(-server.getMaxTimeoutMs());
- final Timestamp timeoutTime = Timestamp.currentTime().addTimeMs(-3L *
server.getMaxTimeoutMs());
+ final Timestamp timeoutTime =
Timestamp.currentTime().addTimeMs(-stagingTimeout.toLong(TimeUnit.MILLISECONDS));
if (follower.getLastRpcResponseTime().compareTo(timeoutTime) < 0) {
LOG.debug("{} detects a follower {} timeout ({}ms) for bootstrapping",
this, follower,
follower.getLastRpcResponseTime().elapsedTimeMs());