diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionInfo.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionInfo.java index 836578c40d3..7a03e052a31 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionInfo.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionInfo.java @@ -802,11 +802,11 @@ public interface RegionInfo { } int startKeyCompare = Bytes.compareTo(getStartKey(), other.getStartKey()); if (startKeyCompare == 0) { - return !this.isSplitParent(); + return true; } if (startKeyCompare < 0) { if (isLast()) { - return !this.isSplitParent(); + return true; } return Bytes.compareTo(getEndKey(), other.getStartKey()) > 0; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java index ec75e0b884e..dbe35995598 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java @@ -617,6 +617,10 @@ public class CatalogJanitor extends ScheduledChore { Bytes.toStringBinary(metaTableRow.getRow()), ri.getRegionNameAsString()); return null; } + // Skip split parent region + if (ri.isSplitParent()) { + return ri; + } // If table is disabled, skip integrity check. if (!isTableDisabled(ri)) { if (isTableTransition(ri)) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HbckChore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HbckChore.java index 5bb4e9524fc..d144937db59 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HbckChore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HbckChore.java @@ -62,6 +62,7 @@ public class HbckChore extends ScheduledChore { private final Map regionInfoMap = new HashMap<>(); private final Set disabledTableRegions = new HashSet<>(); + private final Set splitParentRegions = new HashSet<>(); /** * The regions only opened on RegionServers, but no region info in meta. @@ -124,6 +125,7 @@ public class HbckChore extends ScheduledChore { running = true; regionInfoMap.clear(); disabledTableRegions.clear(); + splitParentRegions.clear(); orphanRegionsOnRS.clear(); orphanRegionsOnFS.clear(); inconsistentRegions.clear(); @@ -190,6 +192,9 @@ public class HbckChore extends ScheduledChore { .isTableState(regionInfo.getTable(), TableState.State.DISABLED)) { disabledTableRegions.add(regionInfo.getEncodedName()); } + if (regionInfo.isSplitParent()) { + splitParentRegions.add(regionInfo.getEncodedName()); + } HbckRegionInfo.MetaEntry metaEntry = new HbckRegionInfo.MetaEntry(regionInfo, regionState.getServerName(), regionState.getStamp()); @@ -222,11 +227,14 @@ public class HbckChore extends ScheduledChore { HbckRegionInfo hri = entry.getValue(); ServerName locationInMeta = hri.getMetaEntry().getRegionServer(); if (hri.getDeployedOn().size() == 0) { - // Because the inconsistent regions are not absolutely right, only skip the offline regions - // which belong to disabled table. + // skip the offline region which belong to disabled table. if (disabledTableRegions.contains(encodedRegionName)) { continue; } + // skip the split parent regions + if (splitParentRegions.contains(encodedRegionName)) { + continue; + } // Master thought this region opened, but no regionserver reported it. inconsistentRegions.put(encodedRegionName, new Pair<>(locationInMeta, new LinkedList<>())); } else if (hri.getDeployedOn().size() > 1) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestHbckChore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestHbckChore.java index a367318dad5..4c0a194e4d1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestHbckChore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestHbckChore.java @@ -39,6 +39,7 @@ import org.apache.hadoop.hbase.master.TableStateManager; import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.testclassification.MasterTests; import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.util.Pair; import org.junit.Before; @@ -180,6 +181,25 @@ public class TestHbckChore extends TestAssignmentManagerBase { assertFalse(inconsistentRegions.containsKey(regionName)); } + @Test + public void testForSplitParent() throws Exception { + TableName tableName = TableName.valueOf("testForSplitParent"); + RegionInfo hri = RegionInfoBuilder.newBuilder(tableName).setStartKey(Bytes.toBytes(0)) + .setEndKey(Bytes.toBytes(1)).setSplit(true).setOffline(true).setRegionId(0).build(); + String regionName = hri.getEncodedName(); + rsDispatcher.setMockRsExecutor(new GoodRsExecutor()); + Future future = submitProcedure(createAssignProcedure(hri)); + waitOnFuture(future); + + List serverNames = master.getServerManager().getOnlineServersList(); + assertEquals(NSERVERS, serverNames.size()); + + hbckChore.choreForTesting(); + Map>> inconsistentRegions = + hbckChore.getInconsistentRegions(); + assertFalse(inconsistentRegions.containsKey(regionName)); + } + @Test public void testOrphanRegionsOnFS() throws Exception { TableName tableName = TableName.valueOf("testOrphanRegionsOnFS"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java index d1cbd92c0a8..ff95f594730 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java @@ -129,11 +129,6 @@ public class TestHRegionInfo { assertFalse(dri.isOverlap(ari)); assertTrue(abri.isOverlap(adri)); assertTrue(adri.isOverlap(abri)); - // Check that splitParent is not reported as an overlap. - RegionInfo splitParent = RegionInfoBuilder.newBuilder(adri.getTable()). - setStartKey(adri.getStartKey()).setEndKey(adri.getEndKey()).setOffline(true). - setSplit(true).build(); - assertFalse(splitParent.isOverlap(abri)); } @Test