From 595655f190d292e9b519362fc49ee951bdafa72d Mon Sep 17 00:00:00 2001 From: stack Date: Wed, 29 Apr 2020 14:33:16 -0700 Subject: [PATCH] HBASE-24247 Failed multi-merge because two regions not adjacent (legitimately). Addendum: Restore old semantic where merge of non-adjacent required 'force' --- .../org/apache/hadoop/hbase/client/RegionInfo.java | 10 ---------- .../java/org/apache/hadoop/hbase/master/MetaFixer.java | 2 +- .../master/assignment/MergeTableRegionsProcedure.java | 4 ++-- .../hadoop/hbase/regionserver/TestHRegionInfo.java | 5 ----- 4 files changed, 3 insertions(+), 18 deletions(-) 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 1d7eb3e9dbd..538d744d676 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 @@ -796,16 +796,6 @@ public interface RegionInfo extends Comparable { 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. * @see #isDegenerate() diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetaFixer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetaFixer.java index 8f374419235..ae29c01e573 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetaFixer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetaFixer.java @@ -219,7 +219,7 @@ class MetaFixer { RegionInfo [] regionsArray = regions.toArray(new RegionInfo [] {}); try { this.masterServices.mergeRegions(regionsArray, - false, HConstants.NO_NONCE, HConstants.NO_NONCE); + true, HConstants.NO_NONCE, HConstants.NO_NONCE); } catch (MergeRegionException mre) { LOG.warn("Failed overlap fix of {}", regionsArray, mre); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/MergeTableRegionsProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/MergeTableRegionsProcedure.java index 0625db73950..6a241c6c4b4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/MergeTableRegionsProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/MergeTableRegionsProcedure.java @@ -133,7 +133,7 @@ public class MergeTableRegionsProcedure LOG.warn(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 " + previous.getShortNameToLog() + ", " + ri.getShortNameToLog() + " when force=false"; LOG.warn(msg); @@ -142,7 +142,7 @@ public class MergeTableRegionsProcedure } 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 { checkOnline(env, ri); 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 67246850492..3e005404f2f 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 @@ -153,11 +153,6 @@ public class TestHRegionInfo { org.apache.hadoop.hbase.client.RegionInfo efri = org.apache.hadoop.hbase.client.RegionInfoBuilder.newBuilder(TableName.META_TABLE_NAME). 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