choubenson commented on code in PR #12122:
URL: https://github.com/apache/iotdb/pull/12122#discussion_r1575827285
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/task/InnerSpaceCompactionTask.java:
##########
@@ -283,30 +227,87 @@ protected boolean doCompaction() {
String.format("%.2f", costTime),
String.format("%.2f", selectedFileSize / 1024.0d / 1024.0d /
costTime),
summary);
- } finally {
- Files.deleteIfExists(logFile.toPath());
- // may failed to set status if the status of target resource is DELETED
- targetTsFileResource.setStatus(TsFileResourceStatus.NORMAL);
}
} catch (Exception e) {
isSuccess = false;
handleException(LOGGER, e);
recover();
} finally {
releaseAllLocks();
+ try {
+ if (logFile != null) {
+ Files.deleteIfExists(logFile.toPath());
+ }
+ } catch (IOException e) {
+ handleException(LOGGER, e);
+ }
+ // may fail to set status if the status of target resource is DELETED
+ targetTsFileResource.setStatus(TsFileResourceStatus.NORMAL);
}
return isSuccess;
}
+ protected void compact(SimpleCompactionLogger compactionLogger) throws
Exception {
+ // carry out the compaction
+ targetTsFileList = new
ArrayList<>(Collections.singletonList(targetTsFileResource));
+ performer.setSourceFiles(selectedTsFileResourceList);
+ // As elements in targetFiles may be removed in performer, we should use a
mutable list
+ // instead of Collections.singletonList()
+ performer.setTargetFiles(targetTsFileList);
+ performer.setSummary(summary);
+ performer.perform();
+
+ prepareTargetFiles();
+
+ if (Thread.currentThread().isInterrupted() || summary.isCancel()) {
+ throw new InterruptedException(
+ String.format("%s-%s [Compaction] abort", storageGroupName,
dataRegionId));
+ }
+
+ validateCompactionResult(
+ sequence ? selectedTsFileResourceList : Collections.emptyList(),
+ sequence ? Collections.emptyList() : selectedTsFileResourceList,
+ targetTsFileList);
+
+ // replace the old files with new file, the new is in same position as the
old
+ tsFileManager.replace(
+ sequence ? selectedTsFileResourceList : Collections.emptyList(),
+ sequence ? Collections.emptyList() : selectedTsFileResourceList,
+ targetTsFileList,
+ timePartition);
+
+ // release the read lock of all source files, and get the write lock of
them to delete them
+ for (int i = 0; i < selectedTsFileResourceList.size(); ++i) {
+ selectedTsFileResourceList.get(i).writeLock();
+ isHoldingWriteLock[i] = true;
+ }
Review Comment:
Comments have been updated. This is old code, compaction now no longer
requires adding and releasing read locks of source files.
--
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]