Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport "HBASE-29073 StochasticLoadBalancer will always run the balancer on st…" to branch-3 #6648

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
HBASE-29073 StochasticLoadBalancer will always run the balancer on st…
…artup because of uninitialized sumMultiplier (#6641)

Co-authored-by: Ray Mattingly <[email protected]>
Signed-off-by: Nick Dimiduk <[email protected]>
rmdmattingly and Ray Mattingly committed Jan 28, 2025

Unverified

No user is associated with the committer email.
commit 490883597d17b504a94f3ba3d267a6d8217280ff
Original file line number Diff line number Diff line change
@@ -421,13 +421,16 @@ boolean needsBalance(TableName tableName, BalancerClusterState cluster) {
}

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 @@ protected List<RegionPlan> balanceTable(TableName tableName,

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");