This is an automated email from the ASF dual-hosted git repository.
rmattingly pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 777010361ab HBASE-29073 StochasticLoadBalancer will always run the
balancer on startup because of uninitialized sumMultiplier (#6641)
777010361ab is described below
commit 777010361abb203b8b17673d84acf4f7f1d0283a
Author: Ray Mattingly <[email protected]>
AuthorDate: Tue Jan 28 15:28:39 2025 -0500
HBASE-29073 StochasticLoadBalancer will always run the balancer on startup
because of uninitialized sumMultiplier (#6641)
Co-authored-by: Ray Mattingly <[email protected]>
Signed-off-by: Nick Dimiduk <[email protected]>
---
.../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");