From 9ac90e7b81de791c575cf2346cec194c02a22ebd Mon Sep 17 00:00:00 2001 From: Grant Palau Spencer Date: Thu, 27 Mar 2025 16:28:56 -0700 Subject: [PATCH] Fall back to current states when best possible calculation fails --- .../stages/BestPossibleStateCalcStage.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java b/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java index 152c766e43..62e6f35d20 100644 --- a/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java +++ b/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java @@ -321,6 +321,18 @@ private BestPossibleStateOutput compute(ClusterEvent event, Map { + if (currentStateOutput.getCurrentStateMap(resourceName).isEmpty()) { + return; + } + IdealState fakeIS = new IdealState(resourceName); + currentStateOutput.getCurrentStateMap(resourceName).forEach((partition, stateMap) -> + fakeIS.setInstanceStateMap(partition.getPartitionName(), stateMap != null ? stateMap : new HashMap<>()) + ); + updateBestPossibleStateOutput(output, resourceMap.get(resourceName), fakeIS); + }); + return output; }