Skip to content

Conversation

benchaplin
Copy link
Contributor

Before this PR: this test makes a search request with allow_partial_search_results=false then manipulates the execution:

  • Allows one shard to proceed, and blocks the others
  • Throws an exception during query execution of that shard
  • Expects the search to be cancelled (because there are no replicas to retry)

Batched query execution handles cancellations in a slightly worse manner. Instead of retrying (or failing if there are no replicas) immediately, batched queries must wait for all shards in the batch to complete. Then the data node responds to the coordinating node with the batch result, which handles shard failures. Therefore, this test doesn't work for batched, because if only one shard is allowed to proceed and it's part of a batched request, the batch will never complete.

After this PR: this test makes a search request with allow_partial_search_results=false then manipulates the execution:

  • Allows one node to proceed, and blocks the others
  • Throws an exception during query execution of one of the shards on that node
  • Expects the search to be cancelled (because there are no replicas to retry)

@benchaplin benchaplin added >test Issues or PRs that are addressing/adding tests auto-backport Automatically create backport pull requests when merged Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch :Search Foundations/Search Catch all for Search Foundations v9.2.0 v9.1.4 labels Aug 26, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

public void onNewReaderContext(ReaderContext c) {
if (runOnNewReaderContext.get() != null) {
runOnNewReaderContext.get().accept(c);
public void onPreQueryPhase(SearchContext c) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change because SearchContext gave me easier access to the node ID.

Both the onNewReaderContext and onPreQueryPhase hooks run before query execution begins, so either will do the job for this test (the only user of SearchShardBlockingPlugin).

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I am only wondering whether we should keep the old test and still run it without batched execution, maybe that's overkill, up to you @benchaplin

@benchaplin
Copy link
Contributor Author

Good shout. I suppose the batched setting will be available for users to disable, so I think we should keep the old test. I've randomized the setting.

@benchaplin benchaplin merged commit 1023131 into elastic:main Aug 28, 2025
33 checks passed
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
9.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged :Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch >test Issues or PRs that are addressing/adding tests v9.1.4 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants