diff --git a/docs/changelog/99222.yaml b/docs/changelog/99222.yaml new file mode 100644 index 0000000000000..025c5e01d2a53 --- /dev/null +++ b/docs/changelog/99222.yaml @@ -0,0 +1,5 @@ +pr: 99222 +summary: Fork response-sending in `OpenPointInTimeAction` +area: Search +type: bug +issues: [] diff --git a/server/src/main/java/org/elasticsearch/action/search/TransportOpenPointInTimeAction.java b/server/src/main/java/org/elasticsearch/action/search/TransportOpenPointInTimeAction.java index 07fed9598ea8b..9c78e5ad62aea 100644 --- a/server/src/main/java/org/elasticsearch/action/search/TransportOpenPointInTimeAction.java +++ b/server/src/main/java/org/elasticsearch/action/search/TransportOpenPointInTimeAction.java @@ -21,7 +21,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.util.concurrent.AtomicArray; +import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.search.SearchPhaseResult; @@ -167,10 +167,29 @@ protected void executePhaseOnShard( @Override protected SearchPhase getNextPhase(SearchPhaseResults results, SearchPhaseContext context) { return new SearchPhase(getName()) { + + private void onExecuteFailure(Exception e) { + onPhaseFailure(this, "sending response failed", e); + } + @Override public void run() { - final AtomicArray atomicArray = results.getAtomicArray(); - sendSearchResponse(InternalSearchResponse.EMPTY_WITH_TOTAL_HITS, atomicArray); + execute(new AbstractRunnable() { + @Override + public void onFailure(Exception e) { + onExecuteFailure(e); + } + + @Override + protected void doRun() { + sendSearchResponse(InternalSearchResponse.EMPTY_WITH_TOTAL_HITS, results.getAtomicArray()); + } + + @Override + public boolean isForceExecution() { + return true; // we already created the PIT, no sense in rejecting the task that sends the response. + } + }); } }; }