diff --git a/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java b/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java index b0d98c39454..72dc8db03a6 100644 --- a/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java +++ b/src/main/java/org/elasticsearch/cluster/service/InternalClusterService.java @@ -336,14 +336,18 @@ public class InternalClusterService extends AbstractLifecycleComponent ackTimeoutCallback; private Throwable lastFailure; - AckCountDownListener(AckedClusterStateUpdateTask ackedUpdateTask, long clusterStateVersion, DiscoveryNodes nodes, ThreadPool threadPool) { + AckCountDownListener(AckedClusterStateUpdateTask ackedUpdateTask, ClusterState clusterState, ThreadPool threadPool) { this.ackedUpdateTask = ackedUpdateTask; - this.version = clusterStateVersion; + this.clusterState = clusterState; int countDown = 0; - for (DiscoveryNode node : nodes) { + for (DiscoveryNode node : clusterState.nodes()) { if (ackedUpdateTask.mustAck(node)) { countDown++; } } - logger.trace("expecting {} acknowledgements for cluster_state update (version: {})", countDown, version); + //we always wait for at least 1 node (the master) + countDown = Math.max(1, countDown); + logger.trace("expecting {} acknowledgements for cluster_state update (version: {})", countDown, clusterState.version()); this.countDown = new CountDown(countDown); this.ackTimeoutCallback = threadPool.schedule(ackedUpdateTask.ackTimeout(), ThreadPool.Names.GENERIC, new Runnable() { @Override @@ -651,17 +657,20 @@ public class InternalClusterService extends AbstractLifecycleComponent