Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -802,11 +802,11 @@ default boolean isOverlap(RegionInfo other) {
}
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,10 @@ private RegionInfo metaTableConsistencyCheck(Result metaTableRow) {
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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -124,6 +125,7 @@ protected synchronized void chore() {
running = true;
regionInfoMap.clear();
disabledTableRegions.clear();
splitParentRegions.clear();
orphanRegionsOnRS.clear();
orphanRegionsOnFS.clear();
inconsistentRegions.clear();
Expand Down Expand Up @@ -190,6 +192,9 @@ private void loadRegionsFromInMemoryState() {
.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());
Expand Down Expand Up @@ -222,11 +227,14 @@ private void loadRegionsFromRSReport() {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
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;
Expand Down Expand Up @@ -180,6 +181,25 @@ public void testForDisabledTable() throws Exception {
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ public void testIsOverlap() {
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
Expand Down