Skip to content

Investigate replacing synchronous execute overloads with the chunked/streaming paths in FetchPhase #144571

@drempapis

Description

@drempapis

Background

As part of #139124, FetchPhase grew a streaming (chunked) execution path alongside the two existing synchronous overloads:

public void execute(SearchContext context, int[] docIdsToLoad, RankDocShardInfo rankDocs)
public void execute(SearchContext context, int[] docIdsToLoad, RankDocShardInfo rankDocs, @Nullable IntConsumer memoryChecker)

To keep the scope of that PR manageable, these overloads were intentionally left in place. This issue tracks the follow-up investigation.

Problem

Maintaining two separate code paths, one synchronous, one chunked, increases complexity and makes future changes to fetch logic more expensive. Ideally we converge on a single implementation.

Call sites to investigate

There are four production call sites using the synchronous overloads. Each needs to be assessed independently for whether it can be migrated to the chunked path:

  1. SearchService.executeFetchPhase, the single-shard optimisation path. When numberOfShards() == 1, query and fetch run in one shot on the same data node with no separate coordinator RPC. Currently passes null for memoryChecker, so default CB accumulation applies.

  2. SearchService.executeRankFeatureFetch, fetches documents for re-ranking, consumed immediately and locally by RankFeatureShardPhase.processFetch. Also passes null.

  3. InnerHitsPhase.hitExecute, a sub-phase that fetches nested/parent-child documents and embeds them into the parent SearchHit. Passes null.

  4. TopHitsAggregator.runFetchPhase, the only caller that supplies a non-null memoryChecker (this::addRequestCircuitBreakerBytes), because the aggregation manages its own circuit breaker accounting separately from the main fetch path.

Goal

Converge on a single fetch execution path (if possible) by migrating all four call sites to the chunked API and removing the synchronous overloads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions