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

yongzao pushed a commit to branch Fix-concurrent-bug
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 996d6288c3c5c92329527c2fd46eb26e39a91cc9
Author: YongzaoDan <[email protected]>
AuthorDate: Tue Apr 16 18:03:39 2024 +0800

    Finish
---
 .../confignode/manager/load/balancer/RouteBalancer.java  | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java
 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java
index dae72dad80d..5c19f0139b7 100644
--- 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java
+++ 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RouteBalancer.java
@@ -108,7 +108,7 @@ public class RouteBalancer implements 
IClusterStatusSubscriber {
   private final Map<TConsensusGroupId, TRegionReplicaSet> regionPriorityMap;
 
   // The interval of retrying to balance ratis leader after the last failed 
time
-  private static final long BALANCE_RATIS_LEADER_FAILED_INTERVAL = 60 * 1000L;
+  private static final long BALANCE_RATIS_LEADER_FAILED_INTERVAL_IN_NS = 60 * 
1000L * 1000L;
   private final Map<TConsensusGroupId, Long> lastFailedTimeForLeaderBalance;
 
   public RouteBalancer(IManager configManager) {
@@ -175,7 +175,7 @@ public class RouteBalancer implements 
IClusterStatusSubscriber {
         (regionGroupId, newLeaderId) -> {
           if (ConsensusFactory.RATIS_CONSENSUS.equals(consensusProtocolClass)
               && currentTime - 
lastFailedTimeForLeaderBalance.getOrDefault(regionGroupId, 0L)
-                  <= BALANCE_RATIS_LEADER_FAILED_INTERVAL) {
+                  <= BALANCE_RATIS_LEADER_FAILED_INTERVAL_IN_NS) {
             return;
           }
 
@@ -283,13 +283,8 @@ public class RouteBalancer implements 
IClusterStatusSubscriber {
     }
 
     if (needBroadcast.get()) {
-      priorityMapLock.readLock().lock();
-      try {
-        broadcastLatestRegionPriorityMap();
-        recordRegionPriorityMap(differentPriorityMap);
-      } finally {
-        priorityMapLock.readLock().unlock();
-      }
+      recordRegionPriorityMap(differentPriorityMap);
+      broadcastLatestRegionPriorityMap();
     }
   }
 
@@ -304,10 +299,11 @@ public class RouteBalancer implements 
IClusterStatusSubscriber {
             .collect(Collectors.toMap(TDataNodeLocation::getDataNodeId, 
location -> location));
 
     long broadcastTime = System.currentTimeMillis();
+    Map<TConsensusGroupId, TRegionReplicaSet> tmpPriorityMap = 
getRegionPriorityMap();
     AsyncClientHandler<TRegionRouteReq, TSStatus> clientHandler =
         new AsyncClientHandler<>(
             DataNodeRequestType.UPDATE_REGION_ROUTE_MAP,
-            new TRegionRouteReq(broadcastTime, regionPriorityMap),
+            new TRegionRouteReq(broadcastTime, tmpPriorityMap),
             dataNodeLocationMap);
     
AsyncDataNodeClientPool.getInstance().sendAsyncRequestToDataNodeWithRetry(clientHandler);
   }

Reply via email to