HBASE-23014 Should not show split parent regions in hbck report UI (#609)

This commit is contained in:
Guanghao Zhang 2019-09-12 01:07:26 +08:00 committed by stack
parent 516e921cc0
commit 9f31d744f6
5 changed files with 36 additions and 9 deletions

View File

@ -802,11 +802,11 @@ public interface RegionInfo {
} }
int startKeyCompare = Bytes.compareTo(getStartKey(), other.getStartKey()); int startKeyCompare = Bytes.compareTo(getStartKey(), other.getStartKey());
if (startKeyCompare == 0) { if (startKeyCompare == 0) {
return !this.isSplitParent(); return true;
} }
if (startKeyCompare < 0) { if (startKeyCompare < 0) {
if (isLast()) { if (isLast()) {
return !this.isSplitParent(); return true;
} }
return Bytes.compareTo(getEndKey(), other.getStartKey()) > 0; return Bytes.compareTo(getEndKey(), other.getStartKey()) > 0;
} }

View File

@ -617,6 +617,10 @@ public class CatalogJanitor extends ScheduledChore {
Bytes.toStringBinary(metaTableRow.getRow()), ri.getRegionNameAsString()); Bytes.toStringBinary(metaTableRow.getRow()), ri.getRegionNameAsString());
return null; return null;
} }
// Skip split parent region
if (ri.isSplitParent()) {
return ri;
}
// If table is disabled, skip integrity check. // If table is disabled, skip integrity check.
if (!isTableDisabled(ri)) { if (!isTableDisabled(ri)) {
if (isTableTransition(ri)) { if (isTableTransition(ri)) {

View File

@ -62,6 +62,7 @@ public class HbckChore extends ScheduledChore {
private final Map<String, HbckRegionInfo> regionInfoMap = new HashMap<>(); private final Map<String, HbckRegionInfo> regionInfoMap = new HashMap<>();
private final Set<String> disabledTableRegions = new HashSet<>(); private final Set<String> disabledTableRegions = new HashSet<>();
private final Set<String> splitParentRegions = new HashSet<>();
/** /**
* The regions only opened on RegionServers, but no region info in meta. * The regions only opened on RegionServers, but no region info in meta.
@ -124,6 +125,7 @@ public class HbckChore extends ScheduledChore {
running = true; running = true;
regionInfoMap.clear(); regionInfoMap.clear();
disabledTableRegions.clear(); disabledTableRegions.clear();
splitParentRegions.clear();
orphanRegionsOnRS.clear(); orphanRegionsOnRS.clear();
orphanRegionsOnFS.clear(); orphanRegionsOnFS.clear();
inconsistentRegions.clear(); inconsistentRegions.clear();
@ -190,6 +192,9 @@ public class HbckChore extends ScheduledChore {
.isTableState(regionInfo.getTable(), TableState.State.DISABLED)) { .isTableState(regionInfo.getTable(), TableState.State.DISABLED)) {
disabledTableRegions.add(regionInfo.getEncodedName()); disabledTableRegions.add(regionInfo.getEncodedName());
} }
if (regionInfo.isSplitParent()) {
splitParentRegions.add(regionInfo.getEncodedName());
}
HbckRegionInfo.MetaEntry metaEntry = HbckRegionInfo.MetaEntry metaEntry =
new HbckRegionInfo.MetaEntry(regionInfo, regionState.getServerName(), new HbckRegionInfo.MetaEntry(regionInfo, regionState.getServerName(),
regionState.getStamp()); regionState.getStamp());
@ -222,11 +227,14 @@ public class HbckChore extends ScheduledChore {
HbckRegionInfo hri = entry.getValue(); HbckRegionInfo hri = entry.getValue();
ServerName locationInMeta = hri.getMetaEntry().getRegionServer(); ServerName locationInMeta = hri.getMetaEntry().getRegionServer();
if (hri.getDeployedOn().size() == 0) { if (hri.getDeployedOn().size() == 0) {
// Because the inconsistent regions are not absolutely right, only skip the offline regions // skip the offline region which belong to disabled table.
// which belong to disabled table.
if (disabledTableRegions.contains(encodedRegionName)) { if (disabledTableRegions.contains(encodedRegionName)) {
continue; continue;
} }
// skip the split parent regions
if (splitParentRegions.contains(encodedRegionName)) {
continue;
}
// Master thought this region opened, but no regionserver reported it. // Master thought this region opened, but no regionserver reported it.
inconsistentRegions.put(encodedRegionName, new Pair<>(locationInMeta, new LinkedList<>())); inconsistentRegions.put(encodedRegionName, new Pair<>(locationInMeta, new LinkedList<>()));
} else if (hri.getDeployedOn().size() > 1) { } else if (hri.getDeployedOn().size() > 1) {

View File

@ -39,6 +39,7 @@ import org.apache.hadoop.hbase.master.TableStateManager;
import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.testclassification.MasterTests; import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests; 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.FSUtils;
import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.hbase.util.Pair;
import org.junit.Before; import org.junit.Before;
@ -180,6 +181,25 @@ public class TestHbckChore extends TestAssignmentManagerBase {
assertFalse(inconsistentRegions.containsKey(regionName)); 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<byte[]> future = submitProcedure(createAssignProcedure(hri));
waitOnFuture(future);
List<ServerName> serverNames = master.getServerManager().getOnlineServersList();
assertEquals(NSERVERS, serverNames.size());
hbckChore.choreForTesting();
Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegions =
hbckChore.getInconsistentRegions();
assertFalse(inconsistentRegions.containsKey(regionName));
}
@Test @Test
public void testOrphanRegionsOnFS() throws Exception { public void testOrphanRegionsOnFS() throws Exception {
TableName tableName = TableName.valueOf("testOrphanRegionsOnFS"); TableName tableName = TableName.valueOf("testOrphanRegionsOnFS");

View File

@ -129,11 +129,6 @@ public class TestHRegionInfo {
assertFalse(dri.isOverlap(ari)); assertFalse(dri.isOverlap(ari));
assertTrue(abri.isOverlap(adri)); assertTrue(abri.isOverlap(adri));
assertTrue(adri.isOverlap(abri)); 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 @Test