Skip to content

Commit

Permalink
fix shard movements
Browse files Browse the repository at this point in the history
  • Loading branch information
ywangd committed Nov 18, 2024
1 parent 2c8feed commit 0b03f4e
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,10 @@ private static List<MoveAllocationCommand> getMoveCommands(AllocationCommands co

private void setCurrentDesiredBalance(DesiredBalance newDesiredBalance) {
// Update current desired balance if the old value has not been changed already by master fail-over
final AtomicReference<DesiredBalance> oldDesiredBalance = new AtomicReference<>();
final DesiredBalance updatedDesiredBalance = currentDesiredBalanceRef.updateAndGet(current -> {
if (current != DesiredBalance.NOT_MASTER) {
oldDesiredBalance.set(current);
return newDesiredBalance;
} else {
return current;
Expand All @@ -300,7 +302,8 @@ private void setCurrentDesiredBalance(DesiredBalance newDesiredBalance) {
} else {
logger.debug("Desired balance updated for [{}]", newDesiredBalance.lastConvergedIndex());
}
computedShardMovements.inc(DesiredBalance.shardMovements(updatedDesiredBalance, newDesiredBalance));
assert oldDesiredBalance.get() != null;
computedShardMovements.inc(DesiredBalance.shardMovements(oldDesiredBalance.get(), newDesiredBalance));
} else {
logger.debug("discard desired balance for [{}]", newDesiredBalance.lastConvergedIndex());
}
Expand Down

0 comments on commit 0b03f4e

Please sign in to comment.