SOLR-17053: If all shards fail, fail the request despite shards.tolerant #2102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/SOLR-17053
Description
If the request is tolerant to errors, logic in SearchHandler simply sets partialResults to true upon detecting an error in ShardResponse. This means a failure to query any shard would be reported back as partialResults=true, instead of a query failure.
Why: Improve the error handling and reporting in the search system by making sure that query failures are distinct from partial results
Solution
Evaluate if all shards failed while fetching top results. If yes, fail the request by throwing a SolrException, if not set partialResults=true
Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
Added a test in TestTolerantSearch: testAllShardsFail() that performs distributed search across 2 shards, but both shards have failures. The test performs the distributed search first by setting shards.tolerant=false and then by toggling it to true. The test confirms that in both cases, a SolrException is thrown. Also ensured existing tests in TestTolerant pass with the new code changes.
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.@dsmiley