diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java index ed7005ee53d..76a4b492493 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryAndFetchAction.java @@ -156,7 +156,11 @@ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAc try { innerFinishHim(); } catch (Exception e) { - listener.onFailure(new ReduceSearchPhaseException("query_fetch", "", e, buildShardFailures())); + ReduceSearchPhaseException failure = new ReduceSearchPhaseException("query_fetch", "", e, buildShardFailures()); + if (logger.isDebugEnabled()) { + logger.debug("failed to reduce search", failure); + } + listener.onFailure(failure); } finally { searchCache.releaseDfsResults(dfsResults); searchCache.releaseQueryFetchResults(queryFetchResults); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java index 9c807324c75..a84ee1c422f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchDfsQueryThenFetchAction.java @@ -249,7 +249,11 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA try { innerFinishHim(); } catch (Exception e) { - listener.onFailure(new ReduceSearchPhaseException("fetch", "", e, buildShardFailures())); + ReduceSearchPhaseException failure = new ReduceSearchPhaseException("fetch", "", e, buildShardFailures()); + if (logger.isDebugEnabled()) { + logger.debug("failed to reduce search", failure); + } + listener.onFailure(failure); } finally { releaseIrrelevantSearchContexts(queryResults, docIdsToLoad); searchCache.releaseDfsResults(dfsResults); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryThenFetchAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryThenFetchAction.java index eeb96b87e41..ba242a78eef 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryThenFetchAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchQueryThenFetchAction.java @@ -163,7 +163,11 @@ public class TransportSearchQueryThenFetchAction extends TransportSearchTypeActi try { innerFinishHim(); } catch (Exception e) { - listener.onFailure(new ReduceSearchPhaseException("fetch", "", e, buildShardFailures())); + ReduceSearchPhaseException failure = new ReduceSearchPhaseException("fetch", "", e, buildShardFailures()); + if (logger.isDebugEnabled()) { + logger.debug("failed to reduce search", failure); + } + listener.onFailure(failure); } finally { releaseIrrelevantSearchContexts(queryResults, docIdsToLoad); searchCache.releaseQueryResults(queryResults); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollScanAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollScanAction.java index ee8af774e62..4def8bea7b7 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollScanAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchScrollScanAction.java @@ -206,7 +206,13 @@ public class TransportSearchScrollScanAction extends AbstractComponent { try { innerFinishHim(); } catch (Exception e) { - listener.onFailure(new ReduceSearchPhaseException("fetch", "", e, buildShardFailures(shardFailures, searchCache))); + ReduceSearchPhaseException failure = new ReduceSearchPhaseException("fetch", "", e, buildShardFailures(shardFailures, searchCache)); + if (logger.isDebugEnabled()) { + logger.debug("failed to reduce search", failure); + } + listener.onFailure(failure); + } finally { + searchCache.releaseQueryFetchResults(queryFetchResults); } } @@ -239,7 +245,6 @@ public class TransportSearchScrollScanAction extends AbstractComponent { // we rebuild the scroll id since we remove shards that we finished scrolling on scrollId = TransportSearchHelper.buildScrollId(this.scrollId.type(), queryFetchResults.values(), this.scrollId.attributes()); // continue moving the total_hits } - searchCache.releaseQueryFetchResults(queryFetchResults); listener.onResponse(new SearchResponse(internalResponse, scrollId, this.scrollId.context().length, successfulOps.get(), System.currentTimeMillis() - startTime, buildShardFailures(shardFailures, searchCache))); }