shuwenwei commented on code in PR #15257:
URL: https://github.com/apache/iotdb/pull/15257#discussion_r2050441665
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/selector/estimator/AbstractCompactionEstimator.java:
##########
@@ -99,31 +131,37 @@ private FileInfo getFileInfoFromCache(TsFileResource
resource) throws IOExceptio
if (fileInfoCache.containsKey(resource)) {
return fileInfoCache.get(resource);
}
- File file = new File(resource.getTsFilePath());
+ TsFileID tsFileID = resource.getTsFileID();
synchronized (globalFileInfoCacheForFailedCompaction) {
- if (globalFileInfoCacheForFailedCompaction.containsKey(file)) {
- FileInfo fileInfo = globalFileInfoCacheForFailedCompaction.get(file);
+ FileInfo fileInfo = globalFileInfoCacheForFailedCompaction.get(tsFileID);
+ if (fileInfo != null) {
fileInfoCache.put(resource, fileInfo);
return fileInfo;
}
}
try (TsFileSequenceReader reader = getReader(resource.getTsFilePath())) {
FileInfo fileInfo = CompactionEstimateUtils.calculateFileInfo(reader);
fileInfoCache.put(resource, fileInfo);
- synchronized (globalFileInfoCacheForFailedCompaction) {
- globalFileInfoCacheForFailedCompaction.put(file, fileInfo);
+ if (isCacheMemoryCostAllocated) {
+ synchronized (globalFileInfoCacheForFailedCompaction) {
+ globalFileInfoCacheForFailedCompaction.put(tsFileID, fileInfo);
+ }
+ synchronized (globalRoughInfoCacheForCompaction) {
+ globalRoughInfoCacheForCompaction.put(tsFileID,
fileInfo.getSimpleFileInfo());
+ }
Review Comment:
These synchronized blocks were a simple fix in past. Maybe synchronized map
is not suitable enough for the LRUMap
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]