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());
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;
}

View File

@ -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)) {

View File

@ -62,6 +62,7 @@ public class HbckChore extends ScheduledChore {
private final Map<String, HbckRegionInfo> regionInfoMap = new HashMap<>();
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.
@ -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) {

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.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<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
public void testOrphanRegionsOnFS() throws Exception {
TableName tableName = TableName.valueOf("testOrphanRegionsOnFS");

View File

@ -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