This is an automated email from the ASF dual-hosted git repository.
rmattingly pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new d7c2a3c9716 HBASE-29073 StochasticLoadBalancer will always run the
balancer on startup because of uninitialized sumMultiplier (#6641) (#6649)
d7c2a3c9716 is described below
commit d7c2a3c971674ad443475aaf81ba17a6271f6359
Author: Ray Mattingly <[email protected]>
AuthorDate: Fri Jan 31 18:30:40 2025 -0500
HBASE-29073 StochasticLoadBalancer will always run the balancer on startup
because of uninitialized sumMultiplier (#6641) (#6649)
Signed-off-by: Nick Dimiduk <[email protected]>
Co-authored-by: Ray Mattingly <[email protected]>
---
.../hadoop/hbase/master/balancer/StochasticLoadBalancer.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
index 017625a715e..fca4ef95207 100644
---
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
+++
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
@@ -442,14 +442,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) {
if (isBalancerRejectionRecording) {
@@ -583,12 +585,13 @@ public class StochasticLoadBalancer extends
BaseLoadBalancer {
long startTime = EnvironmentEdgeManager.currentTime();
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");