From 52443d41cf8aa328990da124abaf2187a5fe352e Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Tue, 26 May 2020 09:29:56 +0200 Subject: [PATCH] Stop async search maintenance service on restart (#56982) This change ensures that we stop the maintenance service on all nodes when a data node is restarted. This ensures that we don't send update_by_query requests on the node that is restarted. This commit also raises the log level to trace for some packages in order to investigate the failures to acquire a shard lock after a restart. Relates #56765 --- .../xpack/search/AsyncSearchActionIT.java | 10 ++++++---- .../xpack/search/AsyncSearchIntegTestCase.java | 9 +++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/AsyncSearchActionIT.java b/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/AsyncSearchActionIT.java index e77f6d07256..eae3be39a98 100644 --- a/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/AsyncSearchActionIT.java +++ b/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/AsyncSearchActionIT.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.search; -import org.apache.lucene.util.LuceneTestCase; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.common.settings.Settings; @@ -17,7 +16,8 @@ import org.elasticsearch.search.aggregations.bucket.terms.StringTerms; import org.elasticsearch.search.aggregations.metrics.InternalMax; import org.elasticsearch.search.aggregations.metrics.InternalMin; import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.test.ESIntegTestCase.SuiteScopeTestCase; +import org.elasticsearch.test.junit.annotations.TestIssueLogging; import org.elasticsearch.xpack.core.search.action.AsyncSearchResponse; import org.elasticsearch.xpack.core.search.action.SubmitAsyncSearchRequest; @@ -37,8 +37,10 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.lessThan; import static org.hamcrest.Matchers.lessThanOrEqualTo; -@ESIntegTestCase.SuiteScopeTestCase -@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/56765") +@SuiteScopeTestCase +@TestIssueLogging( + value = "org.elasticsearch.index:TRACE,org.elasticsearch.env:TRACE", + issueUrl = "https://github.com/elastic/elasticsearch/issues/56765") public class AsyncSearchActionIT extends AsyncSearchIntegTestCase { private static String indexName; private static int numShards; diff --git a/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java b/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java index 64fcf943a75..578092ac9b7 100644 --- a/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java +++ b/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java @@ -134,12 +134,9 @@ public abstract class AsyncSearchIntegTestCase extends ESIntegTestCase { final ClusterStateResponse clusterState = client().admin().cluster() .prepareState().clear().setNodes(true).get(); DiscoveryNode node = clusterState.getState().nodes().get(searchId.getTaskId().getNodeId()); - internalCluster().restartNode(node.getName(), new InternalTestCluster.RestartCallback() { - @Override - public Settings onNodeStopped(String nodeName) throws Exception { - return super.onNodeStopped(nodeName); - } - }); + stopMaintenanceService(); + internalCluster().restartNode(node.getName(), new InternalTestCluster.RestartCallback() {}); + startMaintenanceService(); ensureYellow(INDEX, indexName); }