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 d0313d1de6ab..dd3e3a263098 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 @@ -94,13 +94,15 @@ private FileInfo getFileInfoFromCache(TsFileResource resource) throws IOExceptio fileInfoCache.put(resource, fileInfo); return fileInfo; } - try (TsFileSequenceReader reader = - new TsFileSequenceReader(resource.getTsFilePath(), true, false)) { - FileInfo fileInfo = CompactionEstimateUtils.calculateFileInfo(reader); - fileInfoCache.put(resource, fileInfo); + } + try (TsFileSequenceReader reader = + new TsFileSequenceReader(resource.getTsFilePath(), true, false)) { + FileInfo fileInfo = CompactionEstimateUtils.calculateFileInfo(reader); + fileInfoCache.put(resource, fileInfo); + synchronized (globalFileInfoCacheForFailedCompaction) { globalFileInfoCacheForFailedCompaction.put(file, fileInfo); - return fileInfo; } + return fileInfo; } }