You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2024/08/09 04:48:27 UTC

(iotdb) 10/19: Enhance transferLeader retry frequency when migrating region #13098

This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch rc/1.3.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit daa834140e5026254ad4a46cb8e4c320123dadfc
Author: Potato <ta...@apache.org>
AuthorDate: Wed Aug 7 12:11:58 2024 +0800

    Enhance transferLeader retry frequency when migrating region #13098
    
    Signed-off-by: OneSizeFitQuorum <ta...@apache.org>
    (cherry picked from commit 43d0fa503544f9f89861d03b1348501eaa8a82c7)
---
 .../iotdb/confignode/procedure/env/RegionMaintainHandler.java  | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java
index 7ef330f460f..4b51208e79f 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/env/RegionMaintainHandler.java
@@ -666,7 +666,7 @@ public class RegionMaintainHandler {
    * @param originalDataNode The DataNode where the region locates
    */
   public void transferRegionLeader(TConsensusGroupId regionId, TDataNodeLocation originalDataNode)
-      throws ProcedureException {
+      throws ProcedureException, InterruptedException {
     // find new leader
     final int findNewLeaderTimeLimitSecond = 10;
     long startTime = System.nanoTime();
@@ -689,6 +689,10 @@ public class RegionMaintainHandler {
             && RATIS_CONSENSUS.equals(CONF.getDataRegionConsensusProtocolClass())) {
       final int MAX_RETRY_TIME = 10;
       int retryTime = 0;
+      long sleepTime =
+          (CONF.getSchemaRegionRatisRpcLeaderElectionTimeoutMaxMs()
+                  + CONF.getSchemaRegionRatisRpcLeaderElectionTimeoutMinMs())
+              / 2;
       while (true) {
         TRegionLeaderChangeResp resp =
             SyncDataNodeClientPool.getInstance()
@@ -702,7 +706,9 @@ public class RegionMaintainHandler {
           LOGGER.warn("[RemoveRegion] Ratis transfer leader fail, but procedure will continue.");
           return;
         }
-        LOGGER.warn("Call changeRegionLeader fail for the {} time", retryTime);
+        LOGGER.warn(
+            "Call changeRegionLeader fail for the {} time, will sleep {} ms", retryTime, sleepTime);
+        Thread.sleep(sleepTime);
       }
     }