From 2fa58b95a112ccb8b98bd8a12013365ae58f0fa2 Mon Sep 17 00:00:00 2001 From: liuzhongjun89 Date: Mon, 9 Jan 2023 21:52:37 +0800 Subject: [PATCH 1/2] HBASE-27560 fix consistencyCheck did not report the hole on last region --- .../master/janitor/ReportMakingVisitor.java | 6 ++--- .../janitor/TestCatalogJanitorCluster.java | 23 ++++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/janitor/ReportMakingVisitor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/janitor/ReportMakingVisitor.java index 8ced538212b9..c712f1cba672 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/janitor/ReportMakingVisitor.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/janitor/ReportMakingVisitor.java @@ -181,10 +181,10 @@ private RegionInfo metaTableConsistencyCheck(Result metaTableRow) { addOverlap(this.highestEndKeyRegionInfo, ri); } } + this.previous = ri; + this.highestEndKeyRegionInfo = + MetaFixer.getRegionInfoWithLargestEndKey(this.highestEndKeyRegionInfo, ri); } - this.previous = ri; - this.highestEndKeyRegionInfo = - MetaFixer.getRegionInfoWithLargestEndKey(this.highestEndKeyRegionInfo, ri); return ri; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/janitor/TestCatalogJanitorCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/janitor/TestCatalogJanitorCluster.java index 18ab5221c8c5..2788677ab277 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/janitor/TestCatalogJanitorCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/janitor/TestCatalogJanitorCluster.java @@ -68,6 +68,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 { @@ -84,6 +86,9 @@ public void before() throws Exception { 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 @@ -231,7 +236,7 @@ private static byte[] incrementRow(byte[] row) { } @Test - public void testHoles() throws IOException { + public void testHoles() throws IOException, InterruptedException { CatalogJanitor janitor = TEST_UTIL.getHBaseCluster().getMaster().getCatalogJanitor(); CatalogJanitorReport report = janitor.getLastReport(); @@ -241,6 +246,9 @@ public void testHoles() throws IOException { 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); @@ -250,8 +258,8 @@ private void fixHoles(CatalogJanitor janitor) throws IOException { 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(); @@ -327,4 +335,13 @@ private RegionInfo getRegionInfo(TableName tableName, byte[] row) throws IOExcep 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."); + } + } } From b8473562ebba02d17264379909349653836cebe5 Mon Sep 17 00:00:00 2001 From: liuzhongjun89 Date: Tue, 10 Jan 2023 10:31:27 +0800 Subject: [PATCH 2/2] HBASE-27560 fix consistencyCheck did not report the hole on last region --- .../hadoop/hbase/master/janitor/TestCatalogJanitorCluster.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/janitor/TestCatalogJanitorCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/janitor/TestCatalogJanitorCluster.java index 2788677ab277..58cef3b0465b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/janitor/TestCatalogJanitorCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/janitor/TestCatalogJanitorCluster.java @@ -32,6 +32,7 @@ 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;