@Override
  public long getEstimatedMemoryCost() {
    if (innerSpaceEstimator == null) {
      innerSpaceEstimator =
          ((IInnerCompactionPerformer) this.performer).getInnerSpaceEstimator().orElse(null);
    }
    if (innerSpaceEstimator != null && memoryCost == 0L) {
      try {
        memoryCost =
            CompactionEstimateUtils.shouldUseRoughEstimatedResult(roughMemoryCost)
                ? roughMemoryCost
                : innerSpaceEstimator.estimateInnerCompactionMemory(
                    filesView.sourceFilesInCompactionPerformer);
      } catch (CompactionSourceFileDeletedException e) {
        innerSpaceEstimator.cleanup();
        return -1;
      } catch (Exception e) {
        if (e instanceof StopReadTsFileByInterruptException || Thread.interrupted()) {
          Thread.currentThread().interrupt();
          return -1;
        }
        innerSpaceEstimator.cleanup();
        // This exception may be caused by drop database
        if (!tsFileManager.isAllowCompaction()) {
          return -1;
        }
        LOGGER.error("Meet error when estimate inner compaction memory", e);
        return -1;
      }
    }
    return memoryCost;
  }
release the read lock and write lock of files if it is held, and set the merging status of
selected files to false.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/task/InnerSpaceCompactionTask.java