diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java
index b6e16f83967..c0c1d7ef944 100644
--- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java
+++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/MetaTableAccessor.java
@@ -290,6 +290,13 @@ public final class MetaTableAccessor {
return getMergeRegions(getRegionResult(connection, regionName).rawCells());
}
+ /**
+ * Check whether the given {@code regionName} has any 'info:merge*' columns.
+ */
+ public static boolean hasMergeRegions(Connection conn, byte[] regionName) throws IOException {
+ return hasMergeRegions(getRegionResult(conn, regionName).rawCells());
+ }
+
/**
* @return Deserialized values of <qualifier,regioninfo> pairs taken from column values that
* match the regex 'info:merge.*' in array of cells
.
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
index e991f3f8ef3..c0e58c48655 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
@@ -163,7 +163,8 @@ public class CatalogJanitor extends ScheduledChore {
* garbage to collect.
* @return How many items gc'd whether for merge or split.
*/
- int scan() throws IOException {
+ @VisibleForTesting
+ public int scan() throws IOException {
int gcs = 0;
try {
if (!alreadyRunning.compareAndSet(false, true)) {
@@ -413,26 +414,6 @@ public class CatalogJanitor extends ScheduledChore {
return this.services.getTableDescriptors().get(tableName);
}
- /**
- * Checks if the specified region has merge qualifiers, if so, try to clean them.
- * @return true if no info:merge* columns; i.e. the specified region doesn't have
- * any merge qualifiers.
- */
- public boolean cleanMergeQualifier(final RegionInfo region) throws IOException {
- // Get merge regions if it is a merged region and already has merge qualifier
- List parents = MetaTableAccessor.getMergeRegions(this.services.getConnection(),
- region.getRegionName());
- if (parents == null || parents.isEmpty()) {
- // It doesn't have merge qualifier, no need to clean
- return true;
- }
-
- // If a parent region is a merged child region and GC has not kicked in/finish its work yet,
- // return false in this case to avoid kicking in a merge, trying later.
- cleanMergeRegion(region, parents);
- return false;
- }
-
/**
* Report made by ReportMakingVisitor
*/
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 68db7b2c1b6..d9c44f91c8e 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
@@ -27,6 +27,7 @@ import java.util.stream.Stream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.MetaMutationAnnotation;
+import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.UnknownRegionException;
@@ -472,12 +473,12 @@ public class MergeTableRegionsProcedure
return false;
}
- CatalogJanitor catalogJanitor = env.getMasterServices().getCatalogJanitor();
RegionStates regionStates = env.getAssignmentManager().getRegionStates();
- for (RegionInfo ri: this.regionsToMerge) {
- if (!catalogJanitor.cleanMergeQualifier(ri)) {
+ for (RegionInfo ri : this.regionsToMerge) {
+ if (MetaTableAccessor.hasMergeRegions(env.getMasterServices().getConnection(),
+ ri.getRegionName())) {
String msg = "Skip merging " + RegionInfo.getShortNameToLog(regionsToMerge) +
- ", because a parent, " + RegionInfo.getShortNameToLog(ri) + ", has a merge qualifier " +
+ ", because a parent, " + RegionInfo.getShortNameToLog(ri) + ", has a merge qualifier " +
"(if a 'merge column' in parent, it was recently merged but still has outstanding " +
"references to its parents that must be cleared before it can participate in merge -- " +
"major compact it to hurry clearing of its references)";
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java
index de98270e819..c5425a21059 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin1.java
@@ -560,7 +560,7 @@ public class TestAdmin1 extends TestAdminBase {
// Need to wait GC for merged child region is done.
HMaster services = TEST_UTIL.getHBaseCluster().getMaster();
CatalogJanitor cj = services.getCatalogJanitor();
- cj.cleanMergeQualifier(mergedChildRegion);
+ assertTrue(cj.scan() > 0);
// Wait until all procedures settled down
while (!services.getMasterProcedureExecutor().getActiveProcIds().isEmpty()) {
Thread.sleep(200);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi2.java
index 1cbde2fa49c..cc680266c10 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi2.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi2.java
@@ -189,7 +189,7 @@ public class TestAsyncRegionAdminApi2 extends TestAsyncAdminBase {
// Need to wait GC for merged child region is done.
HMaster services = TEST_UTIL.getHBaseCluster().getMaster();
CatalogJanitor cj = services.getCatalogJanitor();
- cj.cleanMergeQualifier(mergedChildRegion);
+ assertTrue(cj.scan() > 0);
// Wait until all procedures settled down
while (!services.getMasterProcedureExecutor().getActiveProcIds().isEmpty()) {
Thread.sleep(200);