This is an automated email from the ASF dual-hosted git repository. tanxinyu pushed a commit to branch close_threshold in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 9980ea88893286e77d4ffc090cec8474b332b3db Author: OneSizeFitQuorum <[email protected]> AuthorDate: Tue Jan 9 13:08:00 2024 +0800 finish Signed-off-by: OneSizeFitQuorum <[email protected]> --- .../confignode/manager/consensus/ConsensusManager.java | 4 ++++ .../org/apache/iotdb/consensus/config/RatisConfig.java | 17 ++++++++++++++--- .../org/apache/iotdb/consensus/ratis/utils/Utils.java | 1 + .../iotdb/db/consensus/DataRegionConsensusImpl.java | 4 ++++ .../iotdb/db/consensus/SchemaRegionConsensusImpl.java | 4 ++++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/consensus/ConsensusManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/consensus/ConsensusManager.java index 75f0a0e59da..0becb2f7cdc 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/consensus/ConsensusManager.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/consensus/ConsensusManager.java @@ -158,6 +158,10 @@ public class ConsensusManager { TimeDuration.valueOf( CONF.getConfigNodeRatisRequestTimeoutMs(), TimeUnit.MILLISECONDS)) + .setSlownessTimeout( + TimeDuration.valueOf( + CONF.getConfigNodeRatisRequestTimeoutMs() * 6, + TimeUnit.MILLISECONDS)) .setFirstElectionTimeoutMin( TimeDuration.valueOf( CONF.getRatisFirstElectionTimeoutMinMs(), diff --git a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/config/RatisConfig.java b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/config/RatisConfig.java index ad40495972b..172b6be1eba 100644 --- a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/config/RatisConfig.java +++ b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/config/RatisConfig.java @@ -273,7 +273,7 @@ public class RatisConfig { * href="https://lists.apache.org/thread/vxd97lpllqtdb8cdbt3nxvg1kv6kjfss">email</a>`. It is * set to 100 years instead of Long.MAX_VALUE to avoid potential overflows when shifting time. */ - private TimeDuration slownessTimeout = TimeDuration.valueOf(100 * 365L, TimeUnit.DAYS); + private TimeDuration slownessTimeout = TimeDuration.valueOf(120, TimeUnit.SECONDS); private TimeDuration firstElectionTimeoutMin = TimeDuration.valueOf(50, TimeUnit.MILLISECONDS); @@ -1145,15 +1145,21 @@ public class RatisConfig { public static class Utils { private final int sleepDeviationThresholdMs; + private final int closeThresholdMs; - private Utils(int sleepDeviationThresholdMs) { + private Utils(int sleepDeviationThresholdMs, int closeThresholdMs) { this.sleepDeviationThresholdMs = sleepDeviationThresholdMs; + this.closeThresholdMs = closeThresholdMs; } public int getSleepDeviationThresholdMs() { return sleepDeviationThresholdMs; } + public int getCloseThresholdMs() { + return closeThresholdMs; + } + public static Utils.Builder newBuilder() { return new Utils.Builder(); } @@ -1161,14 +1167,19 @@ public class RatisConfig { public static class Builder { private int sleepDeviationThresholdMs = 4 * 1000; + private int closeThresholdMs = Integer.MAX_VALUE; public Utils build() { - return new Utils(sleepDeviationThresholdMs); + return new Utils(sleepDeviationThresholdMs, closeThresholdMs); } public void setSleepDeviationThresholdMs(int sleepDeviationThresholdMs) { this.sleepDeviationThresholdMs = sleepDeviationThresholdMs; } + + public void setCloseThresholdMs(int closeThresholdMs) { + this.closeThresholdMs = closeThresholdMs; + } } } } diff --git a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/utils/Utils.java b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/utils/Utils.java index c66ffa70ae8..29de306ba84 100644 --- a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/utils/Utils.java +++ b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/utils/Utils.java @@ -327,6 +327,7 @@ public class Utils { RaftServerConfigKeys.setSleepDeviationThreshold( properties, config.getUtils().getSleepDeviationThresholdMs()); + RaftServerConfigKeys.setCloseThreshold(properties, config.getUtils().getCloseThresholdMs()); final TimeDuration clientMaxRetryGap = getMaxRetrySleepTime(config.getClient()); RaftServerConfigKeys.RetryCache.setExpiryTime(properties, clientMaxRetryGap); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java index 8c41edd7f09..dcdd8bea4a4 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java @@ -144,6 +144,10 @@ public class DataRegionConsensusImpl { TimeDuration.valueOf( CONF.getDataRatisConsensusRequestTimeoutMs(), TimeUnit.MILLISECONDS)) + .setSlownessTimeout( + TimeDuration.valueOf( + CONF.getDataRatisConsensusRequestTimeoutMs() * 6, + TimeUnit.MILLISECONDS)) .setFirstElectionTimeoutMin( TimeDuration.valueOf( CONF.getRatisFirstElectionTimeoutMinMs(), diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/SchemaRegionConsensusImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/SchemaRegionConsensusImpl.java index 711fa5d36a2..a2f4d95bc48 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/SchemaRegionConsensusImpl.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/SchemaRegionConsensusImpl.java @@ -105,6 +105,10 @@ public class SchemaRegionConsensusImpl { TimeDuration.valueOf( CONF.getSchemaRatisConsensusRequestTimeoutMs(), TimeUnit.MILLISECONDS)) + .setSlownessTimeout( + TimeDuration.valueOf( + CONF.getSchemaRatisConsensusRequestTimeoutMs() * 6, + TimeUnit.MILLISECONDS)) .setFirstElectionTimeoutMin( TimeDuration.valueOf( CONF.getRatisFirstElectionTimeoutMinMs(),
