From d55bd707a3603e787ad34e08917705f2424335c1 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Wed, 21 Sep 2016 18:13:26 +0200 Subject: [PATCH] Update incoming recoveries stats when shadow replica is reinitialized (#20612) When an active shadow replica is reinitialized during primary promotion, the recovery stats that are used by the allocation decider settings `cluster.routing.allocation.node_concurrent_recoveries` and `cluster.routing.allocation.node_concurrent_incoming_recoveries` have to be updated. --- .../elasticsearch/cluster/routing/RoutingNodes.java | 1 + .../IndicesClusterStateServiceRandomUpdatesTests.java | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java index 553e3b73247..bd5113029c4 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java @@ -706,6 +706,7 @@ public class RoutingNodes implements Iterable { updateAssigned(candidate, reinitializedShard); inactivePrimaryCount++; inactiveShardCount++; + addRecovery(reinitializedShard); return reinitializedShard; } diff --git a/core/src/test/java/org/elasticsearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java b/core/src/test/java/org/elasticsearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java index a4cdabb0b3b..a102f8dff28 100644 --- a/core/src/test/java/org/elasticsearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java +++ b/core/src/test/java/org/elasticsearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java @@ -206,10 +206,14 @@ public class IndicesClusterStateServiceRandomUpdatesTests extends AbstractIndice break; } String name = "index_" + randomAsciiOfLength(15).toLowerCase(Locale.ROOT); - CreateIndexRequest request = new CreateIndexRequest(name, Settings.builder() + Settings.Builder settingsBuilder = Settings.builder() .put(SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 3)) - .put(SETTING_NUMBER_OF_REPLICAS, randomInt(2)) - .build()).waitForActiveShards(ActiveShardCount.NONE); + .put(SETTING_NUMBER_OF_REPLICAS, randomInt(2)); + if (randomBoolean()) { + settingsBuilder.put(IndexMetaData.SETTING_SHADOW_REPLICAS, true) + .put(IndexMetaData.SETTING_SHARED_FILESYSTEM, true); + } + CreateIndexRequest request = new CreateIndexRequest(name, settingsBuilder.build()).waitForActiveShards(ActiveShardCount.NONE); state = cluster.createIndex(state, request); assertTrue(state.metaData().hasIndex(name)); }