This is an automated email from the ASF dual-hosted git repository.
CRZbulabula pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new 9cadc71a819 [To dev/1.3] Load balance patch (#17463) (#17493) (#17527)
9cadc71a819 is described below
commit 9cadc71a8190bd9b114ef660edc7423df9d97ad3
Author: Yongzao <[email protected]>
AuthorDate: Tue Apr 21 14:21:09 2026 +0800
[To dev/1.3] Load balance patch (#17463) (#17493) (#17527)
---
.../manager/load/service/EventService.java | 5 ++++
.../plan/analyze/ClusterPartitionFetcher.java | 30 ++++++++++++++++------
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/service/EventService.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/service/EventService.java
index 5f6035f0bca..8267227c7ce 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/service/EventService.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/service/EventService.java
@@ -114,6 +114,11 @@ public class EventService {
currentEventServiceFuture = null;
LOGGER.info("Event service is stopped successfully.");
}
+ synchronized (this) {
+ previousNodeStatisticsMap.clear();
+ previousRegionGroupStatisticsMap.clear();
+ previousConsensusGroupStatisticsMap.clear();
+ }
}
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ClusterPartitionFetcher.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ClusterPartitionFetcher.java
index ff19dd79cf5..eb65666035a 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ClusterPartitionFetcher.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ClusterPartitionFetcher.java
@@ -59,7 +59,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -421,16 +420,31 @@ public class ClusterPartitionFetcher implements
IPartitionFetcher {
String database = entry1.getKey();
final Map<TSeriesPartitionSlot, TRegionReplicaSet> result1 =
regionReplicaMap.computeIfAbsent(database, k -> new HashMap<>());
+ Map<TSeriesPartitionSlot, TConsensusGroupId> seriesPartitionTable =
entry1.getValue();
+
+ if (seriesPartitionTable.size() == 1) {
+ // Fast collection in case of query for single device
+ Map.Entry<TSeriesPartitionSlot, TConsensusGroupId>
seriesPartitionEntry =
+ seriesPartitionTable.entrySet().iterator().next();
+ List<TRegionReplicaSet> regionReplicaSets =
+ partitionCache.getRegionReplicaSet(
+ Collections.singletonList(seriesPartitionEntry.getValue()));
+ result1.put(seriesPartitionEntry.getKey(), regionReplicaSets.get(0));
+ continue;
+ }
- Map<TSeriesPartitionSlot, TConsensusGroupId> orderedMap =
- new LinkedHashMap<>(entry1.getValue());
- List<TConsensusGroupId> orderedGroupIds = new
ArrayList<>(orderedMap.values());
+ List<TConsensusGroupId> distinctRegionGroupIds =
+ new ArrayList<>(new HashSet<>(seriesPartitionTable.values()));
List<TRegionReplicaSet> regionReplicaSets =
- partitionCache.getRegionReplicaSet(orderedGroupIds);
+ partitionCache.getRegionReplicaSet(distinctRegionGroupIds);
+ Map<TConsensusGroupId, TRegionReplicaSet> groupIdToReplicaSet = new
HashMap<>();
+ for (int index = 0; index < distinctRegionGroupIds.size(); index++) {
+ groupIdToReplicaSet.put(distinctRegionGroupIds.get(index),
regionReplicaSets.get(index));
+ }
- int index = 0;
- for (Map.Entry<TSeriesPartitionSlot, TConsensusGroupId> entry2 :
orderedMap.entrySet()) {
- result1.put(entry2.getKey(), regionReplicaSets.get(index++));
+ for (Map.Entry<TSeriesPartitionSlot, TConsensusGroupId> entry2 :
+ seriesPartitionTable.entrySet()) {
+ result1.put(entry2.getKey(),
groupIdToReplicaSet.get(entry2.getValue()));
}
}