You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by rm...@apache.org on 2025/01/31 23:30:38 UTC
(hbase) branch branch-3 updated: HBASE-29073 StochasticLoadBalancer will always run the balancer on startup because of uninitialized sumMultiplier (#6641) (#6648)
This is an automated email from the ASF dual-hosted git repository.
rmattingly pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-3 by this push:
new 3a83e2a35b9 HBASE-29073 StochasticLoadBalancer will always run the balancer on startup because of uninitialized sumMultiplier (#6641) (#6648)
3a83e2a35b9 is described below
commit 3a83e2a35b92771c5526aaa256636f067ec46a04
Author: Ray Mattingly <rm...@apache.org>
AuthorDate: Fri Jan 31 18:30:32 2025 -0500
HBASE-29073 StochasticLoadBalancer will always run the balancer on startup because of uninitialized sumMultiplier (#6641) (#6648)
Signed-off-by: Nick Dimiduk <nd...@apache.org>
Co-authored-by: Ray Mattingly <rm...@hubspot.com>
---
.../hadoop/hbase/master/balancer/StochasticLoadBalancer.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
index 4b7a23c0eb2..31d02fa71d6 100644
--- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
+++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
@@ -421,13 +421,16 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
}
double total = 0.0;
+ float localSumMultiplier = 0; // in case this.sumMultiplier is not initialized
for (CostFunction c : costFunctions) {
if (!c.isNeeded()) {
LOG.trace("{} not needed", c.getClass().getSimpleName());
continue;
}
total += c.cost() * c.getMultiplier();
+ localSumMultiplier += c.getMultiplier();
}
+ sumMultiplier = localSumMultiplier;
boolean balanced = (total / sumMultiplier < minCostNeedBalance);
if (balanced) {
@@ -536,12 +539,13 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
initCosts(cluster);
- sumMultiplier = 0;
+ float localSumMultiplier = 0;
for (CostFunction c : costFunctions) {
if (c.isNeeded()) {
- sumMultiplier += c.getMultiplier();
+ localSumMultiplier += c.getMultiplier();
}
}
+ sumMultiplier = localSumMultiplier;
if (sumMultiplier <= 0) {
LOG.error("At least one cost function needs a multiplier > 0. For example, set "
+ "hbase.master.balancer.stochastic.regionCountCost to a positive value or default");