diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/adaptiveallocations/AdaptiveAllocationsScalerService.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/adaptiveallocations/AdaptiveAllocationsScalerService.java index 6c59add730052..bbe90f769818b 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/adaptiveallocations/AdaptiveAllocationsScalerService.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/adaptiveallocations/AdaptiveAllocationsScalerService.java @@ -259,12 +259,17 @@ public synchronized void start() { } public synchronized void stop() { + clusterService.removeListener(this); stopScheduling(); metrics.close(); } @Override public void clusterChanged(ClusterChangedEvent event) { + if (event.metadataChanged() == false) { + return; + } + updateAutoscalers(event.state()); if (scalers.isEmpty() == false) { startScheduling();