diff --git a/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index c786f57029d..d3a656c59fc 100644 --- a/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/core/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -191,39 +191,29 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent> iterator = failedShards.entrySet().iterator(); iterator.hasNext(); ) { + Map.Entry entry = iterator.next(); + ShardId failedShardId = entry.getKey(); + ShardRouting failedShardRouting = entry.getValue(); + IndexRoutingTable indexRoutingTable = routingTable.index(failedShardId.getIndex()); + if (indexRoutingTable == null) { + iterator.remove(); + continue; } - } - - Set hasAllocations = new HashSet<>(); - for (ShardRouting routing : event.state().getRoutingNodes().node(event.state().nodes().localNodeId())) { - hasAllocations.add(routing.index()); - } - for (IndexService indexService : indicesService) { - Index index = indexService.index(); - if (hasAllocations.contains(index) == false) { - assert indexService.shardIds().isEmpty() : - "no locally assigned shards, but index wasn't emptied by applyDeletedShards." - + " index " + index + ", shards: " + indexService.shardIds(); - if (logger.isDebugEnabled()) { - logger.debug("{} cleaning index (no shards allocated)", index); - } - // clean the index - removeIndex(index, "removing index (no shards allocated)"); + IndexShardRoutingTable shardRoutingTable = indexRoutingTable.shard(failedShardId.id()); + if (shardRoutingTable == null) { + iterator.remove(); + continue; + } + if (shardRoutingTable.assignedShards().stream().noneMatch(shr -> shr.isSameAllocation(failedShardRouting))) { + iterator.remove(); } } } @@ -305,23 +295,39 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent hasAllocations = new HashSet<>(); + for (ShardRouting routing : event.state().getRoutingNodes().node(event.state().nodes().localNodeId())) { + hasAllocations.add(routing.index()); + } + for (IndexService indexService : indicesService) { + Index index = indexService.index(); + if (hasAllocations.contains(index) == false) { + assert indexService.shardIds().isEmpty() : + "no locally assigned shards, but index wasn't emptied by applyDeletedShards." + + " index " + index + ", shards: " + indexService.shardIds(); if (logger.isDebugEnabled()) { - logger.debug("[{}] creating index", indexMetaData.getIndex()); - } - try { - indicesService.createIndex(nodeServicesProvider, indexMetaData, buildInIndexListener); - } catch (Throwable e) { - sendFailShard(shard, "failed to create index", e); + logger.debug("{} cleaning index (no shards allocated)", index); } + // clean the index + removeIndex(index, "removing index (no shards allocated)"); } } } @@ -349,6 +355,26 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent> iterator = failedShards.entrySet().iterator(); iterator.hasNext(); ) { - Map.Entry entry = iterator.next(); - ShardId failedShardId = entry.getKey(); - ShardRouting failedShardRouting = entry.getValue(); - IndexRoutingTable indexRoutingTable = routingTable.index(failedShardId.getIndex()); - if (indexRoutingTable == null) { - iterator.remove(); - continue; - } - IndexShardRoutingTable shardRoutingTable = indexRoutingTable.shard(failedShardId.id()); - if (shardRoutingTable == null) { - iterator.remove(); - continue; - } - if (shardRoutingTable.assignedShards().stream().noneMatch(shr -> shr.isSameAllocation(failedShardRouting))) { - iterator.remove(); - } - } - } - private void applyInitializingShard(final ClusterState state, final IndexMetaData indexMetaData, IndexService indexService, final ShardRouting shardRouting) { final RoutingTable routingTable = state.routingTable(); final DiscoveryNodes nodes = state.getNodes(); diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java b/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java index d105c98f4ac..322ed269bcf 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java @@ -40,6 +40,7 @@ public class IndexPrimaryRelocationIT extends ESIntegTestCase { private static final int RELOCATION_COUNT = 25; + @TestLogging("_root:DEBUG,action.delete:TRACE,action.index:TRACE,index.shard:TRACE,cluster.service:TRACE") public void testPrimaryRelocationWhileIndexing() throws Exception { internalCluster().ensureAtLeastNumDataNodes(randomIntBetween(2, 3)); client().admin().indices().prepareCreate("test") diff --git a/docs/reference/search/percolate.asciidoc b/docs/reference/search/percolate.asciidoc index 44400f5b816..700c4ed392c 100644 --- a/docs/reference/search/percolate.asciidoc +++ b/docs/reference/search/percolate.asciidoc @@ -1,8 +1,8 @@ [[search-percolate]] == Percolator -added[5.0.0,Percolator queries modifications aren't visible immediately and a refresh is required] +deprecated[5.0.0,Percolate and multi percolate APIs are deprecated and have been replaced by the new <>] -added[5.0.0,Percolate and multi percolate APIs have been deprecated and has been replaced by <>] +added[5.0.0,Percolator query modifications only become visible after a refresh has occurred. Previously, they became visible immediately] -added[5.0.0,For indices created on or after version 5.0.0 the percolator automatically indexes the query terms with the percolator queries this allows the percolator to percolate documents quicker. It is advisable to reindex any pre 5.0.0 indices to take advantage of this new optimization] +added[5.0.0,For indices created on or after version 5.0.0-alpha1 the percolator automatically indexes the query terms with the percolator queries. This allows the percolator to percolate documents more quickly. It is advisable to reindex any pre 5.0.0 indices to take advantage of this new optimization] diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.snapshots.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.snapshots.json index b54bee38c24..68468dd542a 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.snapshots.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.snapshots.json @@ -8,6 +8,7 @@ "parts": { "repository": { "type" : "list", + "required": true, "description": "Name of repository from which to fetch the snapshot information" } }, diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index 207593725db..1c95372f94c 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -30,6 +30,7 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; +import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag; import org.elasticsearch.cache.recycler.PageCacheRecycler; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; @@ -1837,7 +1838,8 @@ public final class InternalTestCluster extends TestCluster { } NodeService nodeService = getInstanceFromNode(NodeService.class, nodeAndClient.node); - NodeStats stats = nodeService.stats(CommonStatsFlags.ALL, false, false, false, false, false, false, false, false, false, false, false); + CommonStatsFlags flags = new CommonStatsFlags(Flag.FieldData, Flag.QueryCache, Flag.Segments); + NodeStats stats = nodeService.stats(flags, false, false, false, false, false, false, false, false, false, false, false); assertThat("Fielddata size must be 0 on node: " + stats.getNode(), stats.getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0L)); assertThat("Query cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getQueryCache().getMemorySizeInBytes(), equalTo(0L)); assertThat("FixedBitSet cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getSegments().getBitsetMemoryInBytes(), equalTo(0L));