From 34d567a133aeb36f7167ac1a685c4098d7cf051e Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Sat, 23 Nov 2013 09:21:35 +0100 Subject: [PATCH] Don't use mock wrapper on relocate stress test for now since it could be the reason for intermediate/occational failures --- src/main/java/org/elasticsearch/search/SearchService.java | 6 +++++- .../search/basic/SearchWhileRelocatingTests.java | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/search/SearchService.java b/src/main/java/org/elasticsearch/search/SearchService.java index f84367deeec..3f0ceb151b2 100644 --- a/src/main/java/org/elasticsearch/search/SearchService.java +++ b/src/main/java/org/elasticsearch/search/SearchService.java @@ -418,6 +418,7 @@ public class SearchService extends AbstractLifecycleComponent { public FetchSearchResult executeFetchPhase(FetchSearchRequest request) throws ElasticSearchException { SearchContext context = findContext(request.id()); contextProcessing(context); + boolean contextFreed = false; try { context.docIdsToLoad(request.docIds(), 0, request.docIdsSize()); context.indexShard().searchService().onPreFetchPhase(context); @@ -425,6 +426,7 @@ public class SearchService extends AbstractLifecycleComponent { fetchPhase.execute(context); if (context.scroll() == null) { freeContext(request.id()); + contextFreed = true; } else { contextProcessedSuccessfully(context); } @@ -433,7 +435,9 @@ public class SearchService extends AbstractLifecycleComponent { } catch (Throwable e) { context.indexShard().searchService().onFailedFetchPhase(context); logger.trace("Fetch phase failed", e); - freeContext(context); + if (!contextFreed) { + freeContext(context); + } throw ExceptionsHelper.convertToRuntime(e); } finally { cleanContext(context); diff --git a/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java b/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java index c0d3fa3fad1..8cb39d51c11 100644 --- a/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java +++ b/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java @@ -57,7 +57,8 @@ public class SearchWhileRelocatingTests extends ElasticsearchIntegrationTest { private void testSearchAndRelocateConcurrently(int numberOfReplicas) throws Exception { final int numShards = between(10, 20); client().admin().indices().prepareCreate("test") - .setSettings(settingsBuilder().put("index.number_of_shards", numShards).put("index.number_of_replicas", numberOfReplicas)) + .setSettings(settingsBuilder().put("index.number_of_shards", numShards).put("index.number_of_replicas", numberOfReplicas) + .put("index.store.type", "niofs")) .addMapping("type1", "loc", "type=geo_point", "test", "type=string").execute().actionGet(); ensureGreen(); List indexBuilders = new ArrayList();