Prevent Leaking Search Tasks on Exceptions in FetchSearchPhase and DfsQueryPhase (#45500) (#45540)

* If `counter.onResult` throws an exception we might leak a transport task because the failure is not handled as a phase failure (instead it bubbles up in the transport service eventually hitting the `onFailure` callback again and couting down the `counter` twice).

Co-authored-by: Jim Ferenczi <jim.ferenczi@elastic.co>
This commit is contained in:
Armin Braun 2019-08-14 14:49:38 +02:00 committed by GitHub
parent 2a70d38439
commit 5f6bc6fc2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -80,7 +80,11 @@ final class DfsQueryPhase extends SearchPhase {
@Override
protected void innerOnResponse(QuerySearchResult response) {
counter.onResult(response);
try {
counter.onResult(response);
} catch (Exception e) {
context.onPhaseFailure(DfsQueryPhase.this, "", e);
}
}
@Override

View File

@ -163,7 +163,11 @@ final class FetchSearchPhase extends SearchPhase {
new SearchActionListener<FetchSearchResult>(shardTarget, shardIndex) {
@Override
public void innerOnResponse(FetchSearchResult result) {
counter.onResult(result);
try {
counter.onResult(result);
} catch (Exception e) {
context.onPhaseFailure(FetchSearchPhase.this, "", e);
}
}
@Override