@Test
  public void testOverlapWithSmallMergeCount() throws Exception {
    TableName tn = TableName.valueOf(this.name.getMethodName());
    try {
      testOverlapCommon(tn);
      HMaster services = TEST_UTIL.getHBaseCluster().getMaster();
      CatalogJanitor cj = services.getCatalogJanitor();
      cj.scan();
      CatalogJanitorReport report = cj.getLastReport();
      assertEquals(6, report.getOverlaps().size());
      assertEquals(2, MetaFixer.calculateMerges(5, report.getOverlaps()).size());

      // The max merge count is set to 5 so overlap regions are divided into
      // two merge requests.
      TEST_UTIL.getHBaseCluster().getMaster().getConfiguration()
        .setInt("hbase.master.metafixer.max.merge.count", 5);

      // Get overlap regions
      HashSet<String> overlapRegions = new HashSet<>();
      for (Pair<RegionInfo, RegionInfo> pair : report.getOverlaps()) {
        overlapRegions.add(pair.getFirst().getRegionNameAsString());
        overlapRegions.add(pair.getSecond().getRegionNameAsString());
      }

      MetaFixer fixer = new MetaFixer(services);
      fixer.fixOverlaps(report);
      AssignmentManager am = services.getAssignmentManager();

      HBaseTestingUtil.await(200, () -> {
        try {
          cj.scan();
          final CatalogJanitorReport postReport = cj.getLastReport();
          RegionStates regionStates = am.getRegionStates();
          RegionStateStore regionStateStore = am.getRegionStateStore();
          // Make sure that two merged regions are opened and GCs are done.
          if (postReport.getOverlaps().size() == 1) {
            Pair<RegionInfo, RegionInfo> pair = postReport.getOverlaps().get(0);
            if (
              (!overlapRegions.contains(pair.getFirst().getRegionNameAsString())
                && regionStates.getRegionState(pair.getFirst()).isOpened())
                && (!overlapRegions.contains(pair.getSecond().getRegionNameAsString())
                  && regionStates.getRegionState(pair.getSecond()).isOpened())
            ) {
              // Make sure GC is done.
              List<RegionInfo> firstParents = regionStateStore.getMergeRegions(pair.getFirst());
              List<RegionInfo> secondParents = regionStateStore.getMergeRegions(pair.getSecond());

              return (firstParents == null || firstParents.isEmpty())
                && (secondParents == null || secondParents.isEmpty());
            }
          }
          return false;
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      });

      // Second run of fixOverlap should fix all.
      report = cj.getLastReport();
      fixer.fixOverlaps(report);

      HBaseTestingUtil.await(20, () -> {
        try {
          // Make sure it GC only once.
          return (cj.scan() > 0);
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      });

      // No holes reported.
      cj.scan();
      final CatalogJanitorReport postReport = cj.getLastReport();
      assertTrue(postReport.isEmpty());

    } finally {
      TEST_UTIL.getHBaseCluster().getMaster().getConfiguration()
        .unset("hbase.master.metafixer.max.merge.count");

      TEST_UTIL.deleteTable(tn);
    }
  }
Just make sure running fixMeta does right thing for the case of a single-region Table where the
region gets dropped. There is nothing much we can do. We can't restore what we don't know about
(at least from a read of hbase:meta).
hbase-server/src/test/java/org/apache/hadoop/hbase/master/janitor/TestMetaFixer.java