From a432406f26761bdd4ca413c31774a9c14ed84cb1 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 18 Nov 2024 12:10:56 +1100 Subject: [PATCH] more fix --- .../allocation/allocator/DesiredBalanceShardsAllocator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceShardsAllocator.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceShardsAllocator.java index 0dc90b167a617..3cf8588974eba 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceShardsAllocator.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceShardsAllocator.java @@ -294,15 +294,15 @@ private void setCurrentDesiredBalance(DesiredBalance newDesiredBalance) { }); if (updatedDesiredBalance == newDesiredBalance) { + assert oldDesiredBalance.get() != null; if (logger.isTraceEnabled()) { - var diff = DesiredBalance.hasChanges(updatedDesiredBalance, newDesiredBalance) - ? "Diff: " + DesiredBalance.humanReadableDiff(updatedDesiredBalance, newDesiredBalance) + var diff = DesiredBalance.hasChanges(oldDesiredBalance.get(), newDesiredBalance) + ? "Diff: " + DesiredBalance.humanReadableDiff(oldDesiredBalance.get(), newDesiredBalance) : "No changes"; logger.trace("Desired balance updated: {}. {}", newDesiredBalance, diff); } else { logger.debug("Desired balance updated for [{}]", newDesiredBalance.lastConvergedIndex()); } - assert oldDesiredBalance.get() != null; computedShardMovements.inc(DesiredBalance.shardMovements(oldDesiredBalance.get(), newDesiredBalance)); } else { logger.debug("discard desired balance for [{}]", newDesiredBalance.lastConvergedIndex());