@Test
  public void testOneDeletionDuringCompaction() throws Exception {
    DataRegion vsgp =
        new DataRegion(
            STORAGE_GROUP_DIR.getPath(),
            "0",
            new TsFileFlushPolicy.DirectFlushPolicy(),
            COMPACTION_TEST_SG);
    registerTimeseriesInMManger(4, 5, true);
    createFiles(2, 2, 3, 300, 0, 0, 50, 50, true, true);
    createFiles(2, 4, 5, 300, 700, 700, 50, 50, true, true);
    createFiles(3, 3, 4, 200, 20, 10020, 30, 30, true, false);
    createFiles(2, 1, 5, 100, 450, 20450, 0, 0, true, false);
    vsgp.getTsFileResourceManager().addAll(seqResources, true);
    vsgp.getTsFileResourceManager().addAll(unseqResources, false);
    MeasurementPath path =
        new MeasurementPath(
            COMPACTION_TEST_SG
                + PATH_SEPARATOR
                + "d"
                + (TsFileGeneratorUtils.getAlignDeviceOffset() + 3)
                + PATH_SEPARATOR
                + "s0");
    DeleteDataNode deleteDataNode =
        new DeleteDataNode(new PlanNodeId("1"), Collections.singletonList(path), 0, 1000);
    deleteDataNode.setSearchIndex(0);
    vsgp.deleteByDevice(
        new MeasurementPath(
            COMPACTION_TEST_SG
                + PATH_SEPARATOR
                + "d"
                + (TsFileGeneratorUtils.getAlignDeviceOffset() + 3)
                + PATH_SEPARATOR
                + "s0"),
        deleteDataNode);

    CrossSpaceCompactionTask task =
        new CrossSpaceCompactionTask(
            0,
            vsgp.getTsFileResourceManager(),
            seqResources,
            unseqResources,
            new FastCompactionPerformer(true),
            0,
            0);
    task.setSourceFilesToCompactionCandidate();
    seqResources.forEach(f -> f.setStatus(TsFileResourceStatus.COMPACTING));
    unseqResources.forEach(f -> f.setStatus(TsFileResourceStatus.COMPACTING));
    // delete data in source file during compaction
    DeleteDataNode deleteDataNode2 =
        new DeleteDataNode(new PlanNodeId("2"), Collections.singletonList(path), 0, 1200);
    deleteDataNode2.setSearchIndex(0);
    vsgp.deleteByDevice(
        new MeasurementPath(
            COMPACTION_TEST_SG
                + PATH_SEPARATOR
                + "d"
                + (TsFileGeneratorUtils.getAlignDeviceOffset() + 3)
                + PATH_SEPARATOR
                + "s0"),
        deleteDataNode2);
    for (int i = 0; i < seqResources.size(); i++) {
      TsFileResource resource = seqResources.get(i);
      resource.resetModFile();
      if (i < 2) {
        Assert.assertFalse(resource.getCompactionModFile().exists());
        Assert.assertFalse(resource.anyModFileExists());
      } else if (i == 2) {
        Assert.assertTrue(resource.anyModFileExists());
        Assert.assertEquals(2, resource.getAllModEntries().size());
      } else {
        Assert.assertTrue(resource.anyModFileExists());
        Assert.assertEquals(1, resource.getAllModEntries().size());
      }
    }
    for (TsFileResource resource : unseqResources) {
      resource.resetModFile();
      Assert.assertFalse(resource.getCompactionModFile().exists());
      Assert.assertFalse(resource.anyModFileExists());
    }
    task.start();
    for (TsFileResource resource : seqResources) {
      Assert.assertFalse(resource.getTsFile().exists());
      Assert.assertFalse(resource.anyModFileExists());
      Assert.assertFalse(resource.getCompactionModFile().exists());
    }
    for (TsFileResource resource : unseqResources) {
      Assert.assertFalse(resource.getTsFile().exists());
      Assert.assertFalse(resource.anyModFileExists());
      Assert.assertFalse(resource.getCompactionModFile().exists());
    }
    for (int i = 0; i < seqResources.size(); i++) {
      TsFileResource seqResource = seqResources.get(i);
      TsFileResource resource =
          new TsFileResource(
              TsFileNameGenerator.increaseCrossCompactionCnt(seqResource.getTsFile()));
      if (i < 2) {
        Assert.assertFalse(resource.getCompactionModFile().exists());
        Assert.assertFalse(resource.anyModFileExists());
      } else {
        Assert.assertFalse(resource.getCompactionModFile().exists());
        Assert.assertFalse(resource.anyModFileExists());
      }
    }
  }
Total 4 seq files and 5 unseq files, each file has different aligned timeseries.

<p>Seq files<br>
first and second file has d0 ~ d1 and s0 ~ s2, time range is 0 ~ 299 and 350 ~ 649, value range
is 0 ~ 299 and 350 ~ 649.<br>
third and forth file has d0 ~ d3 and s0 ~ S4,time range is 700 ~ 999 and 1050 ~ 1349, value
range is 700 ~ 999 and 1050 ~ 1349.<br>

<p>UnSeq files<br>
first, second and third file has d0 ~ d2 and s0 ~ s3, time range is 20 ~ 219, 250 ~ 449 and 480
~ 679, value range is 10020 ~ 10219, 10250 ~ 10449 and 10480 ~ 10679.<br>
forth and fifth file has d0 and s0 ~ s4, time range is 450 ~ 549 and 550 ~ 649, value range is
20450 ~ 20549 and 20550 ~ 20649.

<p>The data of d3.s0 is deleted. Test when there is a deletion to the file before compaction,
then comes to a deletion during compaction.
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/cross/RewriteCrossSpaceCompactionWithFastPerformerTest.java