From a22529cceb36a0708f6bfe125917ae96192c9a18 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Fri, 25 Mar 2016 13:16:12 +0100 Subject: [PATCH 1/5] Do not retrieve all indices stats when checking for cache resets --- .../main/java/org/elasticsearch/test/InternalTestCluster.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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)); From 30d78f4be023f7f6426f699e7bda773b256086e2 Mon Sep 17 00:00:00 2001 From: Clinton Gormley Date: Fri, 25 Mar 2016 14:23:52 +0100 Subject: [PATCH 2/5] In cat.snapshots, repository is required Closes #17216 --- .../src/main/resources/rest-api-spec/api/cat.snapshots.json | 1 + 1 file changed, 1 insertion(+) 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" } }, From 3da7393b00636e21d0ae7c99f419bddfdf0eedb4 Mon Sep 17 00:00:00 2001 From: Clinton Gormley Date: Fri, 25 Mar 2016 15:36:51 +0100 Subject: [PATCH 3/5] Tidied up percolator doc annotations --- docs/reference/search/percolate.asciidoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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] From 749a851f932dfefbe774fe9391ddd67f5315321f Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Fri, 25 Mar 2016 17:09:50 +0100 Subject: [PATCH 4/5] Order methods in IndicesClusterStateService according to execution --- .../cluster/IndicesClusterStateService.java | 145 +++++++++--------- 1 file changed, 72 insertions(+), 73 deletions(-) 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(); From 6c15e782af5ec4cfb69a29d7706a4d8792696a15 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Fri, 25 Mar 2016 17:25:52 +0100 Subject: [PATCH 5/5] Add some debug logging to testPrimaryRelocationWhileIndexing --- .../elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java | 1 + 1 file changed, 1 insertion(+) 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")