Skip to content

Commit 60c44f1

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. Add TRACE level logging.
1 parent 00fec24 commit 60c44f1

File tree

1 file changed

+17
-3
lines changed
  • hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,23 +571,37 @@ public ServerName getRegionServerOfRegion(RegionInfo regionInfo) {
571571
* wants to iterate this exported list. We need to synchronize on regions
572572
* since all access to this.servers is under a lock on this.regions.
573573
*
574-
* @return A clone of current assignments.
574+
* @return A clone of current open or opening assignments.
575575
*/
576576
public Map<TableName, Map<ServerName, List<RegionInfo>>> getAssignmentsForBalancer(
577577
TableStateManager tableStateManager, List<ServerName> onlineServers) {
578578
final Map<TableName, Map<ServerName, List<RegionInfo>>> result = new HashMap<>();
579579
for (RegionStateNode node : regionsMap.values()) {
580+
// DisableTableProcedure first sets the table state to DISABLED and then force unassigns
581+
// the regions in a loop. The balancer should ignore all regions for tables in DISABLED
582+
// state because even if still currently open we expect them to be offlined very soon.
580583
if (isTableDisabled(tableStateManager, node.getTable())) {
584+
if (LOG.isTraceEnabled()) {
585+
LOG.trace("Ignoring " + node + " because table is disabled");
586+
}
581587
continue;
582588
}
583-
if (node.getRegionInfo().isSplitParent()) {
589+
// When balancing, we are only interested in OPEN or OPENING regions. These can be
590+
// expected to remain online until the next balancer iteration or unless the balancer
591+
// decides to move it. Regions in other states are not eligible for balancing, because
592+
// they are closing, splitting, merging, or otherwise already in transition.
593+
if (!node.isInState(State.OPEN, State.OPENING)) {
594+
if (LOG.isTraceEnabled()) {
595+
LOG.trace("Ignoring " + node + " because region is not OPEN or OPENING");
596+
}
584597
continue;
585598
}
586599
Map<ServerName, List<RegionInfo>> tableResult =
587600
result.computeIfAbsent(node.getTable(), t -> new HashMap<>());
588601
final ServerName serverName = node.getRegionLocation();
602+
// A region in ONLINE or OPENING state should have a location.
589603
if (serverName == null) {
590-
LOG.info("Skipping, no server for " + node);
604+
LOG.warn("Skipping, no server for " + node);
591605
continue;
592606
}
593607
List<RegionInfo> serverResult =

0 commit comments

Comments
 (0)