protected int[] executeInsertionCompaction(
      List<Long> timePartitions, CompactionScheduleContext context) throws InterruptedException {
    int[] trySubmitCountOfTimePartitions = new int[timePartitions.size()];
    CompactionScheduler.sharedLockCompactionSelection();
    try {
      while (true) {
        int currentSubmitCount = 0;
        for (int i = 0; i < timePartitions.size(); i++) {
          long timePartition = timePartitions.get(i);
          int selectedTaskNum =
              CompactionScheduler.scheduleInsertionCompaction(
                  tsFileManager, timePartition, context);
          currentSubmitCount += selectedTaskNum;
          trySubmitCountOfTimePartitions[i] += selectedTaskNum;
          context.clearTimePartitionDeviceInfoCache();
        }
        if (currentSubmitCount <= 0) {
          break;
        }
        context.incrementSubmitTaskNum(CompactionTaskType.INSERTION, currentSubmitCount);
      }
    } catch (InterruptedException e) {
      throw e;
    } catch (Throwable e) {
      logger.error("Meet error in insertion compaction schedule.", e);
    } finally {
      context.clearTimePartitionDeviceInfoCache();
      CompactionScheduler.sharedUnlockCompactionSelection();
    }
    return trySubmitCountOfTimePartitions;
  }
Schedule settle compaction for ttl check.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java