HBASE-27560 fix consistencyCheck did not report the hole on last region (#4950)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
(cherry picked from commit c1b9d8ba06)
This commit is contained in:
liuzhongjun 2023-01-11 18:03:20 +08:00 committed by Duo Zhang
parent 0382b348cb
commit 56ebf93870
2 changed files with 24 additions and 6 deletions

View File

@ -180,10 +180,10 @@ class ReportMakingVisitor implements MetaTableAccessor.CloseableVisitor {
addOverlap(this.highestEndKeyRegionInfo, ri);
}
}
}
this.previous = ri;
this.highestEndKeyRegionInfo =
MetaFixer.getRegionInfoWithLargestEndKey(this.highestEndKeyRegionInfo, ri);
}
return ri;
}

View File

@ -31,6 +31,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotEnabledException;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
@ -66,6 +67,8 @@ public class TestCatalogJanitorCluster {
private static final TableName T3 = TableName.valueOf("t3");
private static final TableName T4 = TableName.valueOf("t4");
private static final TableName T5 = TableName.valueOf("t5");
private static final TableName T6 = TableName.valueOf("t6");
private static final TableName T7 = TableName.valueOf("t7");
@Before
public void before() throws Exception {
@ -82,6 +85,9 @@ public class TestCatalogJanitorCluster {
final byte[][] keysForT5 = { Bytes.toBytes("bb"), Bytes.toBytes("cc"), Bytes.toBytes("dd") };
TEST_UTIL.createTable(T5, HConstants.CATALOG_FAMILY, keysForT5);
TEST_UTIL.createMultiRegionTable(T6, new byte[][] { HConstants.CATALOG_FAMILY });
TEST_UTIL.createMultiRegionTable(T7, new byte[][] { HConstants.CATALOG_FAMILY });
}
@After
@ -227,7 +233,7 @@ public class TestCatalogJanitorCluster {
}
@Test
public void testHoles() throws IOException {
public void testHoles() throws IOException, InterruptedException {
CatalogJanitor janitor = TEST_UTIL.getHBaseCluster().getMaster().getCatalogJanitor();
CatalogJanitorReport report = janitor.getLastReport();
@ -237,6 +243,9 @@ public class TestCatalogJanitorCluster {
verifyCornerHoles(janitor, T1);
// Verify start and end region holes
verifyCornerHoles(janitor, T2);
// Verify start and end region holes when next table is disable see: HBASE-27560
disableTable(T7);
verifyCornerHoles(janitor, T6);
verifyMiddleHole(janitor);
// Verify that MetaFixer is able to fix these holes
fixHoles(janitor);
@ -246,8 +255,8 @@ public class TestCatalogJanitorCluster {
MetaFixer metaFixer = new MetaFixer(TEST_UTIL.getHBaseCluster().getMaster());
janitor.scan();
CatalogJanitorReport report = janitor.getLastReport();
// Verify total number of holes, 2 in t1 and t2 each and one in t3
assertEquals("Number of holes are not matching", 5, report.getHoles().size());
// Verify total number of holes, 2 in t1, t2, t6 each and one in t3
assertEquals("Number of holes are not matching", 7, report.getHoles().size());
metaFixer.fix();
janitor.scan();
report = janitor.getLastReport();
@ -320,4 +329,13 @@ public class TestCatalogJanitorCluster {
assertNotNull(regionInfo);
return regionInfo;
}
private void disableTable(TableName tableName) throws IOException, InterruptedException {
try {
TEST_UTIL.getAdmin().disableTable(tableName);
TEST_UTIL.waitTableDisabled(tableName, 30000);
} catch (TableNotEnabledException e) {
LOG.debug("Table: " + tableName + " already disabled, ignore.");
}
}
}