HBASE-24247 Failed multi-merge because two regions not adjacent (legitimately).

Addendum: Restore old semantic where merge of non-adjacent required
'force'
This commit is contained in:
stack 2020-04-29 14:33:16 -07:00
parent a97395d4c0
commit e3c5527ce5
4 changed files with 3 additions and 18 deletions

View File

@ -796,16 +796,6 @@ public interface RegionInfo extends Comparable<RegionInfo> {
return !isLast() && Bytes.compareTo(getStartKey(), getEndKey()) > 0; return !isLast() && Bytes.compareTo(getStartKey(), getEndKey()) > 0;
} }
default boolean isOverlap(RegionInfo [] ris) {
for (RegionInfo ri: ris) {
if (isOverlap(ri)) {
return true;
}
}
return false;
}
/** /**
* @return True if an overlap in region range. * @return True if an overlap in region range.
* @see #isDegenerate() * @see #isDegenerate()

View File

@ -219,7 +219,7 @@ class MetaFixer {
RegionInfo [] regionsArray = regions.toArray(new RegionInfo [] {}); RegionInfo [] regionsArray = regions.toArray(new RegionInfo [] {});
try { try {
this.masterServices.mergeRegions(regionsArray, this.masterServices.mergeRegions(regionsArray,
false, HConstants.NO_NONCE, HConstants.NO_NONCE); true, HConstants.NO_NONCE, HConstants.NO_NONCE);
} catch (MergeRegionException mre) { } catch (MergeRegionException mre) {
LOG.warn("Failed overlap fix of {}", regionsArray, mre); LOG.warn("Failed overlap fix of {}", regionsArray, mre);
} }

View File

@ -133,7 +133,7 @@ public class MergeTableRegionsProcedure
LOG.warn(msg); LOG.warn(msg);
throw new MergeRegionException(msg); throw new MergeRegionException(msg);
} }
if (!force && !ri.isAdjacent(previous) && !ri.isOverlap(regions)) { if (!force && !ri.isAdjacent(previous) && !ri.isOverlap(previous)) {
String msg = "Unable to merge non-adjacent or non-overlapping regions " + String msg = "Unable to merge non-adjacent or non-overlapping regions " +
previous.getShortNameToLog() + ", " + ri.getShortNameToLog() + " when force=false"; previous.getShortNameToLog() + ", " + ri.getShortNameToLog() + " when force=false";
LOG.warn(msg); LOG.warn(msg);
@ -142,7 +142,7 @@ public class MergeTableRegionsProcedure
} }
if (ri.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID) { if (ri.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID) {
throw new MergeRegionException("Can't merge non-default/replicaId!=0 replicas; " + ri); throw new MergeRegionException("Can't merge non-default replicas; " + ri);
} }
try { try {
checkOnline(env, ri); checkOnline(env, ri);

View File

@ -153,11 +153,6 @@ public class TestHRegionInfo {
org.apache.hadoop.hbase.client.RegionInfo efri = org.apache.hadoop.hbase.client.RegionInfo efri =
org.apache.hadoop.hbase.client.RegionInfoBuilder.newBuilder(TableName.META_TABLE_NAME). org.apache.hadoop.hbase.client.RegionInfoBuilder.newBuilder(TableName.META_TABLE_NAME).
setStartKey(e).setEndKey(f).build(); setStartKey(e).setEndKey(f).build();
RegionInfo [] subsumes = new RegionInfo [] {ari, abri, eri};
assertTrue(abri.isOverlap(subsumes));
subsumes = new RegionInfo [] {ari, cdri, eri};
assertTrue(cdri.isOverlap(subsumes));
assertFalse(efri.isOverlap(subsumes));
} }
@Test @Test