From ff119f3dffbd8144c0cf61b4edf41c363d54db91 Mon Sep 17 00:00:00 2001 From: Britta Weber Date: Sun, 31 May 2015 12:48:56 +0200 Subject: [PATCH] send request to release search context in finally block to be on the save side --- .../type/TransportSearchDfsQueryAndFetchAction.java | 13 ++++++++----- .../TransportSearchDfsQueryThenFetchAction.java | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java index 98a5972af0e..01eefdb564d 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java @@ -104,11 +104,14 @@ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAc @Override public void onFailure(Throwable t) { - onSecondPhaseFailure(t, querySearchRequest, shardIndex, dfsResult, counter); - // the query might not have been executed at all (for example because thread pool rejected execution) - // and the search context that was created in dfs phase might not be released. - // release it again to be in the safe side - sendReleaseSearchContext(querySearchRequest.id(), node); + try { + onSecondPhaseFailure(t, querySearchRequest, shardIndex, dfsResult, counter); + } finally { + // the query might not have been executed at all (for example because thread pool rejected execution) + // and the search context that was created in dfs phase might not be released. + // release it again to be in the safe side + sendReleaseSearchContext(querySearchRequest.id(), node); + } } }); } diff --git a/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java b/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java index 7b96cc97225..3a4e6d70533 100644 --- a/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java +++ b/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java @@ -113,11 +113,14 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA @Override public void onFailure(Throwable t) { - onQueryFailure(t, querySearchRequest, shardIndex, dfsResult, counter); - // the query might not have been executed at all (for example because thread pool rejected execution) - // and the search context that was created in dfs phase might not be released. - // release it again to be in the safe side - sendReleaseSearchContext(querySearchRequest.id(), node); + try { + onQueryFailure(t, querySearchRequest, shardIndex, dfsResult, counter); + } finally { + // the query might not have been executed at all (for example because thread pool rejected execution) + // and the search context that was created in dfs phase might not be released. + // release it again to be in the safe side + sendReleaseSearchContext(querySearchRequest.id(), node); + } } }); }