release search context after the caller listener is invoked

This commit is contained in:
kimchy 2010-05-02 14:22:59 +03:00
parent 1323fe8b5e
commit b7bcc6ccb6
5 changed files with 14 additions and 11 deletions

View File

@ -157,6 +157,9 @@ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAc
innerFinishHim();
} catch (Exception e) {
invokeListener(new ReduceSearchPhaseException("query_fetch", "", e, buildShardFailures()));
} finally {
searchCache.releaseDfsResults(dfsResults);
searchCache.releaseQueryFetchResults(queryFetchResults);
}
}
@ -167,8 +170,6 @@ public class TransportSearchDfsQueryAndFetchAction extends TransportSearchTypeAc
if (request.scroll() != null) {
scrollId = buildScrollId(request.searchType(), dfsResults);
}
searchCache.releaseDfsResults(dfsResults);
searchCache.releaseQueryFetchResults(queryFetchResults);
invokeListener(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successulOps.get(), buildShardFailures()));
}
}

View File

@ -249,6 +249,11 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA
innerFinishHim();
} catch (Exception e) {
invokeListener(new ReduceSearchPhaseException("fetch", "", e, buildShardFailures()));
} finally {
releaseIrrelevantSearchContexts(queryResults, docIdsToLoad);
searchCache.releaseDfsResults(dfsResults);
searchCache.releaseQueryResults(queryResults);
searchCache.releaseFetchResults(fetchResults);
}
}
@ -258,10 +263,6 @@ public class TransportSearchDfsQueryThenFetchAction extends TransportSearchTypeA
if (request.scroll() != null) {
scrollId = TransportSearchHelper.buildScrollId(request.searchType(), dfsResults);
}
releaseIrrelevantSearchContexts(queryResults, docIdsToLoad);
searchCache.releaseDfsResults(dfsResults);
searchCache.releaseQueryResults(queryResults);
searchCache.releaseFetchResults(fetchResults);
invokeListener(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successulOps.get(), buildShardFailures()));
}
}

View File

@ -83,8 +83,8 @@ public class TransportSearchQueryAndFetchAction extends TransportSearchTypeActio
if (request.scroll() != null) {
scrollId = buildScrollId(request.searchType(), queryFetchResults.values());
}
searchCache.releaseQueryFetchResults(queryFetchResults);
invokeListener(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successulOps.get(), buildShardFailures()));
searchCache.releaseQueryFetchResults(queryFetchResults);
}
}
}

View File

@ -164,6 +164,10 @@ public class TransportSearchQueryThenFetchAction extends TransportSearchTypeActi
innerFinishHim();
} catch (Exception e) {
invokeListener(new ReduceSearchPhaseException("fetch", "", e, buildShardFailures()));
} finally {
releaseIrrelevantSearchContexts(queryResults, docIdsToLoad);
searchCache.releaseQueryResults(queryResults);
searchCache.releaseFetchResults(fetchResults);
}
}
@ -173,9 +177,6 @@ public class TransportSearchQueryThenFetchAction extends TransportSearchTypeActi
if (request.scroll() != null) {
scrollId = TransportSearchHelper.buildScrollId(request.searchType(), queryResults.values());
}
releaseIrrelevantSearchContexts(queryResults, docIdsToLoad);
searchCache.releaseQueryResults(queryResults);
searchCache.releaseFetchResults(fetchResults);
invokeListener(new SearchResponse(internalResponse, scrollId, expectedSuccessfulOps, successulOps.get(), buildShardFailures()));
}
}

View File

@ -235,9 +235,9 @@ public class TransportSearchScrollQueryThenFetchAction extends AbstractComponent
if (request.scroll() != null) {
scrollId = request.scrollId();
}
invokeListener(new SearchResponse(internalResponse, scrollId, this.scrollId.values().length, successfulOps.get(), buildShardFailures(shardFailures, searchCache)));
searchCache.releaseQueryResults(queryResults);
searchCache.releaseFetchResults(fetchResults);
invokeListener(new SearchResponse(internalResponse, scrollId, this.scrollId.values().length, successfulOps.get(), buildShardFailures(shardFailures, searchCache)));
}
protected void invokeListener(final SearchResponse response) {