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

haonan 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 035be504296 Fix concurrent modification exception of compaction worker 
(#12011)
035be504296 is described below

commit 035be504296e514358376b112256efeb3dcc2fb5
Author: shuwenwei <[email protected]>
AuthorDate: Wed Jan 31 18:46:25 2024 +0800

    Fix concurrent modification exception of compaction worker (#12011)
---
 .../estimator/AbstractCompactionEstimator.java     | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/estimator/AbstractCompactionEstimator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/estimator/AbstractCompactionEstimator.java
index 77517edbc08..d0313d1de6a 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/estimator/AbstractCompactionEstimator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/estimator/AbstractCompactionEstimator.java
@@ -88,17 +88,19 @@ public abstract class AbstractCompactionEstimator {
       return fileInfoCache.get(resource);
     }
     File file = new File(resource.getTsFilePath());
-    if (globalFileInfoCacheForFailedCompaction.containsKey(file)) {
-      FileInfo fileInfo = globalFileInfoCacheForFailedCompaction.get(file);
-      fileInfoCache.put(resource, fileInfo);
-      return fileInfo;
-    }
-    try (TsFileSequenceReader reader =
-        new TsFileSequenceReader(resource.getTsFilePath(), true, false)) {
-      FileInfo fileInfo = CompactionEstimateUtils.calculateFileInfo(reader);
-      fileInfoCache.put(resource, fileInfo);
-      globalFileInfoCacheForFailedCompaction.put(file, fileInfo);
-      return fileInfo;
+    synchronized (globalFileInfoCacheForFailedCompaction) {
+      if (globalFileInfoCacheForFailedCompaction.containsKey(file)) {
+        FileInfo fileInfo = globalFileInfoCacheForFailedCompaction.get(file);
+        fileInfoCache.put(resource, fileInfo);
+        return fileInfo;
+      }
+      try (TsFileSequenceReader reader =
+          new TsFileSequenceReader(resource.getTsFilePath(), true, false)) {
+        FileInfo fileInfo = CompactionEstimateUtils.calculateFileInfo(reader);
+        fileInfoCache.put(resource, fileInfo);
+        globalFileInfoCacheForFailedCompaction.put(file, fileInfo);
+        return fileInfo;
+      }
     }
   }
 
@@ -169,6 +171,8 @@ public abstract class AbstractCompactionEstimator {
     if (resource == null || resource.getTsFile() == null) {
       return;
     }
-    globalFileInfoCacheForFailedCompaction.remove(resource.getTsFile());
+    synchronized (globalFileInfoCacheForFailedCompaction) {
+      globalFileInfoCacheForFailedCompaction.remove(resource.getTsFile());
+    }
   }
 }

Reply via email to