HBASE-24942 MergeTableRegionsProcedure should not call clean merge region (#2301)
Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
4455856e9c
commit
e61a3460a7
|
@ -383,8 +383,15 @@ public class MetaTableAccessor {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Deserialized values of <qualifier,regioninfo> pairs taken from column values that match
|
||||
* the regex 'info:merge.*' in array of <code>cells</code>.
|
||||
* 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 <code>cells</code>.
|
||||
*/
|
||||
@Nullable
|
||||
public static Map<String, RegionInfo> getMergeRegionsWithName(Cell [] cells) {
|
||||
|
|
|
@ -161,7 +161,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)) {
|
||||
|
@ -411,26 +412,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<RegionInfo> 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
|
||||
*/
|
||||
|
|
|
@ -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,10 +473,10 @@ public class MergeTableRegionsProcedure
|
|||
return false;
|
||||
}
|
||||
|
||||
CatalogJanitor catalogJanitor = env.getMasterServices().getCatalogJanitor();
|
||||
RegionStates regionStates = env.getAssignmentManager().getRegionStates();
|
||||
for (RegionInfo ri : this.regionsToMerge) {
|
||||
if (!catalogJanitor.cleanMergeQualifier(ri)) {
|
||||
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 " +
|
||||
"(if a 'merge column' in parent, it was recently merged but still has outstanding " +
|
||||
|
|
|
@ -553,7 +553,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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue