Skip to content

Commit 1e3959c

Browse files
committed
HBASE-25836 RegionStates#getAssignmentsForBalancer should only care about OPEN or OPENING regions
RegionStates#getAssignmentsForBalancer is used by the HMaster to collect all regions of interest to the balancer for the next chore iteration. We check if a table is in disabled state to exclude regions that will not be of interest (because disabled regions are or will be offline) or are in a state where they shouldn't be mutated (like SPLITTING). The current checks are not actually comprehensive. Filter out regions not in OPEN or OPENING state when building the set of interesting regions for the balancer to consider. Only regions open (or opening) on the cluster are of interest to balancing calculations for the current iteration. Regions in all other states can be expected to not be of interest – either offline (OFFLINE, or FAILED_*), not subject to balancer decisions now (SPLITTING, SPLITTING_NEW, MERGING, MERGING_NEW), or will be offline shortly (CLOSING) – until at least the next chore iteration.
1 parent 00fec24 commit 1e3959c

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

  • hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment

hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStates.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.apache.hadoop.hbase.ServerName;
3737
import org.apache.hadoop.hbase.TableName;
3838
import org.apache.hadoop.hbase.client.RegionInfo;
39-
import org.apache.hadoop.hbase.client.TableState;
4039
import org.apache.hadoop.hbase.master.RegionState;
4140
import org.apache.hadoop.hbase.master.RegionState.State;
4241
import org.apache.hadoop.hbase.master.TableStateManager;
@@ -571,23 +570,25 @@ public ServerName getRegionServerOfRegion(RegionInfo regionInfo) {
571570
* wants to iterate this exported list. We need to synchronize on regions
572571
* since all access to this.servers is under a lock on this.regions.
573572
*
574-
* @return A clone of current assignments.
573+
* @return A clone of current open or opening assignments.
575574
*/
576575
public Map<TableName, Map<ServerName, List<RegionInfo>>> getAssignmentsForBalancer(
577576
TableStateManager tableStateManager, List<ServerName> onlineServers) {
578577
final Map<TableName, Map<ServerName, List<RegionInfo>>> result = new HashMap<>();
579578
for (RegionStateNode node : regionsMap.values()) {
580-
if (isTableDisabled(tableStateManager, node.getTable())) {
581-
continue;
582-
}
583-
if (node.getRegionInfo().isSplitParent()) {
579+
// When balancing, we are only interested in OPEN or OPENING regions and expected
580+
// to be online at that server until possibly the next balancer iteration or unless
581+
// we decide to move it. Other states are not interesting as the region will either
582+
// be closing, or splitting/merging, or will not be deployed.
583+
if (!(node.isInState(State.OPEN)||node.isInState(State.OPENING))) {
584584
continue;
585585
}
586586
Map<ServerName, List<RegionInfo>> tableResult =
587587
result.computeIfAbsent(node.getTable(), t -> new HashMap<>());
588588
final ServerName serverName = node.getRegionLocation();
589+
// A region in ONLINE or OPENING state should have a location.
589590
if (serverName == null) {
590-
LOG.info("Skipping, no server for " + node);
591+
LOG.warn("Skipping, no server for " + node);
591592
continue;
592593
}
593594
List<RegionInfo> serverResult =
@@ -603,12 +604,6 @@ public Map<TableName, Map<ServerName, List<RegionInfo>>> getAssignmentsForBalanc
603604
return result;
604605
}
605606

606-
private boolean isTableDisabled(final TableStateManager tableStateManager,
607-
final TableName tableName) {
608-
return tableStateManager.isTableState(tableName, TableState.State.DISABLED,
609-
TableState.State.DISABLING);
610-
}
611-
612607
// ==========================================================================
613608
// Region in transition helpers
614609
// ==========================================================================

0 commit comments

Comments
 (0)