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

tanxinyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 43d0fa50354 Enhance transferLeader retry frequency when migrating 
region #13098
43d0fa50354 is described below

commit 43d0fa503544f9f89861d03b1348501eaa8a82c7
Author: Potato <[email protected]>
AuthorDate: Wed Aug 7 12:11:58 2024 +0800

    Enhance transferLeader retry frequency when migrating region #13098
    
    Signed-off-by: OneSizeFitQuorum <[email protected]>
---
 .../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);
       }
     }
 

Reply via email to