qiaojialin commented on a change in pull request #4498:
URL: https://github.com/apache/iotdb/pull/4498#discussion_r765505673
##########
File path:
server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/sizetiered/SizeTieredCompactionTask.java
##########
@@ -233,4 +215,149 @@ public boolean checkValidAndSetMerging() {
}
return true;
}
+
+ public void handleException(File logFile, TsFileResource targetTsFile) {
+ boolean handleSuccess = true;
+ if (logFile.exists()) {
+ // if the compaction log file does not exist
+ // it means the compaction process didn't start yet
+ // we need not to handle it
+ boolean allSourceFileExist = true;
+ List<TsFileResource> lostSourceFiles = new ArrayList<>();
+ for (TsFileResource sourceTsFile : selectedTsFileResourceList) {
+ if (!sourceTsFile.getTsFile().exists()) {
+ allSourceFileExist = false;
+ lostSourceFiles.add(sourceTsFile);
+ }
+ }
+ if (allSourceFileExist) {
+ // all source file exists, delete the target file
+ LOGGER.info(
+ "{} [Compaction][ExceptionHandler] all source files {} exists,
delete target file {}",
+ fullStorageGroupName,
+ selectedTsFileResourceList,
+ targetTsFile);
+ targetTsFile.remove();
+ if (targetTsFile.getTsFile().exists()) {
+ LOGGER.warn(
+ "{} [Compaction][ExceptionHandler] failed to remove target file
{}, set allowCompaction to false",
+ fullStorageGroupName,
+ targetTsFile);
+ tsFileManager.setAllowCompaction(false);
+ handleSuccess = false;
+ } else {
+ for (TsFileResource tsFileResource : selectedTsFileResourceList) {
+ if (!tsFileResourceList.contains(tsFileResource)) {
+ tsFileResourceList.add(tsFileResource);
+ }
+ }
+ tsFileResourceList.remove(targetTsFile);
+ }
+ } else {
+ // some source file does not exists
+ // it means we start to delete source file
+ LOGGER.info(
+ "{} [Compaction][ExceptionHandler] some source files {} is lost",
+ fullStorageGroupName,
+ lostSourceFiles);
+ if (targetTsFile.getTsFile().exists()) {
+ try {
+ RestorableTsFileIOWriter writer =
+ new RestorableTsFileIOWriter(targetTsFile.getTsFile());
+ writer.close();
+ if (!writer.hasCrashed()) {
+ // target file is complete, delete source files
+ LOGGER.info(
+ "{} [Compaction][ExceptionHandler] target file {} is
complete, delete remaining source files",
+ fullStorageGroupName,
+ targetTsFile);
+ for (TsFileResource sourceFile : selectedTsFileResourceList) {
+ sourceFile.remove();
Review comment:
add return bool
--
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]