This is an automated email from the ASF dual-hosted git repository. Caideyipi pushed a commit to branch fix/region-group-cache-race in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 1037cbf10fd09f7d34c5c12d9c8af0d79ca70bf5 Author: Caideyipi <[email protected]> AuthorDate: Tue Jul 7 09:31:05 2026 +0800 Fix RegionGroupCache activation race --- .../confignode/manager/load/cache/region/RegionGroupCache.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/region/RegionGroupCache.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/region/RegionGroupCache.java index e441054b1df..2cdecc757fd 100644 --- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/region/RegionGroupCache.java +++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/cache/region/RegionGroupCache.java @@ -66,7 +66,7 @@ public class RegionGroupCache { * @param newHeartbeatSample The newest RegionHeartbeatSample * @param overwrite Able to overwrite Adding or Removing */ - public void cacheHeartbeatSample( + public synchronized void cacheHeartbeatSample( int dataNodeId, RegionHeartbeatSample newHeartbeatSample, boolean overwrite) { // Only cache sample when the corresponding loadCache exists Optional.ofNullable(regionCacheMap.get(dataNodeId)) @@ -83,7 +83,7 @@ public class RegionGroupCache { * * @param dataNodeId the specified DataNode */ - public void createRegionCache(int dataNodeId, TConsensusGroupId groupId) { + public synchronized void createRegionCache(int dataNodeId, TConsensusGroupId groupId) { regionCacheMap.put(dataNodeId, new RegionCache(dataNodeId, groupId)); } @@ -92,7 +92,7 @@ public class RegionGroupCache { * * @param dataNodeId the specified DataNode */ - public void removeRegionCache(int dataNodeId) { + public synchronized void removeRegionCache(int dataNodeId) { regionCacheMap.remove(dataNodeId); } @@ -100,7 +100,7 @@ public class RegionGroupCache { * Update currentStatistics based on the latest NodeHeartbeatSamples that cached in the * slidingWindow. */ - public void updateCurrentStatistics() { + public synchronized void updateCurrentStatistics() { regionCacheMap.values().forEach(regionCache -> regionCache.updateCurrentStatistics(false)); Map<Integer, RegionStatistics> regionStatisticsMap = regionCacheMap.entrySet().stream()
