Skip to content

Commit c8f3dd5

Browse files
committed
HBASE-25836 RegionStates#getAssignmentsForBalancer should only care about OPEN or OPENING regions (#3219)
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. Signed-off-by: Bharath Vissapragada <bharathv@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org>
1 parent 60055f5 commit c8f3dd5

1 file changed

Lines changed: 17 additions & 3 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: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,23 +553,37 @@ public ServerName getRegionServerOfRegion(RegionInfo regionInfo) {
553553
* wants to iterate this exported list. We need to synchronize on regions
554554
* since all access to this.servers is under a lock on this.regions.
555555
*
556-
* @return A clone of current assignments.
556+
* @return A clone of current open or opening assignments.
557557
*/
558558
public Map<TableName, Map<ServerName, List<RegionInfo>>> getAssignmentsForBalancer(
559559
TableStateManager tableStateManager, List<ServerName> onlineServers) {
560560
final Map<TableName, Map<ServerName, List<RegionInfo>>> result = new HashMap<>();
561561
for (RegionStateNode node : regionsMap.values()) {
562+
// DisableTableProcedure first sets the table state to DISABLED and then force unassigns
563+
// the regions in a loop. The balancer should ignore all regions for tables in DISABLED
564+
// state because even if still currently open we expect them to be offlined very soon.
562565
if (isTableDisabled(tableStateManager, node.getTable())) {
566+
if (LOG.isTraceEnabled()) {
567+
LOG.trace("Ignoring {} because table is disabled", node);
568+
}
563569
continue;
564570
}
565-
if (node.getRegionInfo().isSplitParent()) {
571+
// When balancing, we are only interested in OPEN or OPENING regions. These can be
572+
// expected to remain online until the next balancer iteration or unless the balancer
573+
// decides to move it. Regions in other states are not eligible for balancing, because
574+
// they are closing, splitting, merging, or otherwise already in transition.
575+
if (!node.isInState(State.OPEN, State.OPENING)) {
576+
if (LOG.isTraceEnabled()) {
577+
LOG.trace("Ignoring {} because region is not OPEN or OPENING", node);
578+
}
566579
continue;
567580
}
568581
Map<ServerName, List<RegionInfo>> tableResult =
569582
result.computeIfAbsent(node.getTable(), t -> new HashMap<>());
570583
final ServerName serverName = node.getRegionLocation();
584+
// A region in ONLINE or OPENING state should have a location.
571585
if (serverName == null) {
572-
LOG.info("Skipping, no server for " + node);
586+
LOG.warn("Skipping, no server for {}", node);
573587
continue;
574588
}
575589
List<RegionInfo> serverResult =

0 commit comments

Comments
 (0)