Repository navigation
Report a PPL result that covers only some of its shards - #5807
Conversation
PR Reviewer Guide 🔍(Review updated until commit 0587190)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 0587190 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 9a87593
Suggestions up to commit 2d4f817
Suggestions up to commit 503c74b
Suggestions up to commit c717eed
Suggestions up to commit d0bd7e9
|
22a208d to
70fb145
Compare
|
Persistent review updated to latest commit 70fb145 |
|
Persistent review updated to latest commit 58fc3f9 |
58fc3f9 to
af1da74
Compare
|
Persistent review updated to latest commit af1da74 |
af1da74 to
4c2d3a6
Compare
|
Persistent review updated to latest commit 4c2d3a6 |
Codecov Report❌ Patch coverage is ❌ Your project check has failed because the head coverage (63.40%) is below the target coverage (99.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #5807 +/- ##
============================================
+ Coverage 63.36% 63.40% +0.04%
- Complexity 8872 8898 +26
============================================
Files 949 950 +1
Lines 40322 40386 +64
Branches 4546 4553 +7
============================================
+ Hits 25549 25608 +59
- Misses 13929 13932 +3
- Partials 844 846 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4c2d3a6 to
d553f91
Compare
|
Persistent review updated to latest commit d553f91 |
* Remove the opt-in partial-result mode for mapping conflicts The mode (#5657) narrowed an aggregation to the index subset where the group field is aggregatable and labelled the result with a warning. It is being dropped: returning a knowingly incomplete answer to make a query faster is the wrong default to offer, and gating it on a cluster setting, a per-request flag and a response-format check made three moving parts that each had to survive the security plugin's transport-to-worker handoff (#5739, #5743, #5758). Removed: PartialResultAggregatePushdown and its hook in CalciteLogicalIndexScan, plugins.query.partial_result.on_mapping_conflict.enabled, the per-request partial_result field, and the warnings-supported format gate that existed only to protect this feature. A conflicted aggregation once again returns the complete result over every index, which since #5646 pushes down as a _source script rather than failing. Kept whole: the warnings channel it introduced -- Warning, QueryResponse.warnings, CalcitePlanContext.addWarning/drainWarnings, and the SimpleJsonResponseFormatter plumbing. Nothing produces a warning after this commit; #5807 is the next producer, reporting a search that covered only some of its shards. Note for reviewers: dropping partial_result from TransportPPLQueryRequest changes that request's wire format. The class version-gates nothing and the field was appended the same way in 3.9, so this is symmetric with how it arrived, but it does mean a mixed 3.9/3.10 cluster must not route PPL across versions. Signed-off-by: Kai Huang <[email protected]> * Drop the per-index mapping retention the feature needed getIndexMappings() on OpenSearchIndex and lastIndexMappings on the describe request existed only so the partitioner could see which index mapped a field which way. Nothing reads them now. The deep copy before merging stays: MergeRuleHelper rewrites the accumulated type's properties in place, so a fetched mapping would otherwise stop describing its own index. Its test now asserts that on the fetched mappings directly rather than through the removed accessor. Signed-off-by: Kai Huang <[email protected]> --------- Signed-off-by: Kai Huang <[email protected]>
9f3945c to
c717eed
Compare
|
Persistent review updated to latest commit c717eed |
c717eed to
503c74b
Compare
|
Persistent review updated to latest commit 503c74b |
The comments and test fixtures around the warnings banner still described the
removed mapping-conflict mode ("Results exclude 1 of 2 indices due to a mapping
conflict"). Point them at a search that reached only some of its shards, the
case opensearch-project/sql#5807 reports under PARTIAL_RESULT.
Signed-off-by: Kai Huang <[email protected]>
OpenSearch answers a search with HTTP 200 as long as one shard responded (search.default_allow_partial_results defaults to true), so a result can omit whole shards. OpenSearchResponse read only the hits and aggregations and discarded _shards, so PPL presented the surviving shards' rows as the whole answer, with no error and no warning: a count of 750 where the answer is 990. Capture the shard outcome and attach a PARTIAL_RESULT warning through the existing warnings channel when the search did not cover every shard. - ShardStats detects all three partial shapes: a failed shard, a shard with no available copy (total > successful + failed, with failed 0 -- the node-drop shape a failed-only check misses), and a timeout. Skipped shards are already counted in successful. - Record from BackgroundSearchScanner on the query thread; the search itself may run on the background pool, whose thread the warning sink cannot see. - A PIT created over only some of its shards pins that subset, so every search against it looks complete. Report the gap at creation, and allow partial creation to match the search path -- forbidding it turned one unassigned shard into a 500 for every cursor or >max_result_window query. - Drain warnings before the timewrap block, whose finally clears the same thread-local and so dropped them for every timewrap query. Scoped to the Calcite path, where the warnings channel is wired. Signed-off-by: Kai Huang <[email protected]>
The warnings array has been part of the PPL JSON response since opensearch-project#5657 but was never described in the protocol reference. Document the PARTIAL_RESULT type, when the field is present, and which formats carry it. Signed-off-by: Kai Huang <[email protected]>
integTestWithSecurity runs only org.opensearch.sql.security.*, so a path whose IT lives elsewhere is never exercised with security installed. The warning travels the response channel that opensearch-project#5739 showed the security transport interceptor can drop on the transport-to-worker handoff, so check it survives for an index-scoped role. The unallocatable index is dropped between tests so no other class in the suite inherits a red cluster. Signed-off-by: Kai Huang <[email protected]>
503c74b to
2d4f817
Compare
|
Persistent review updated to latest commit 2d4f817 |
| { | ||
| "type": "PARTIAL_RESULT", | ||
| "message": "Results are partial: 1 of 4 shards did not return data.", | ||
| "detail": "Rows and aggregate values from the shards that did not respond are missing, so counts may be undercounted. No copy of those shards was available -- a node may be down or a shard unassigned. Retry the query, or set search.default_allow_partial_results to false so such searches fail instead of returning a subset." |
There was a problem hiding this comment.
Does this required? Opensearch response is enough shards: total:x, failed:y, success:z?
There was a problem hiding this comment.
Updated: detail now carries the shard counts as OpenSearch reports them (_shards: total 4, successful 3, skipped 0, failed 0), plus timed_out and failure reasons when present. message stays as the one-line summary.
| // result partial, which the response reports, rather than failing the query outright. | ||
| CreatePitRequest createPitRequest = | ||
| new CreatePitRequest(cursorKeepAlive, false, indexName.getIndexNames()); | ||
| new CreatePitRequest(cursorKeepAlive, true, indexName.getIndexNames()); |
There was a problem hiding this comment.
how PIT creation warning returnned?
There was a problem hiding this comment.
The warning is recorded when the PIT is created. A PIT created over only some shards pins that subset, so later searches on it look complete (1 of 1 shards); only the create response shows the gap (1 of 2). OpenSearchNodeClient.createPit turns that into a warning on the query thread, and it's returned with the other warnings. Verified with one shard unassigned. Added unit tests for this path.
Signed-off-by: Kai Huang <[email protected]>
|
Persistent review updated to latest commit 9a87593 |
The detail now carries the shard counts as OpenSearch reported them, plus any failure reasons, instead of a written explanation. Format with Locale.ROOT so the numbers don't depend on the JVM locale. Signed-off-by: Kai Huang <[email protected]>
|
Persistent review updated to latest commit 0587190 |
…ch-project#5814) * Remove the opt-in partial-result mode for mapping conflicts The mode (opensearch-project#5657) narrowed an aggregation to the index subset where the group field is aggregatable and labelled the result with a warning. It is being dropped: returning a knowingly incomplete answer to make a query faster is the wrong default to offer, and gating it on a cluster setting, a per-request flag and a response-format check made three moving parts that each had to survive the security plugin's transport-to-worker handoff (opensearch-project#5739, opensearch-project#5743, opensearch-project#5758). Removed: PartialResultAggregatePushdown and its hook in CalciteLogicalIndexScan, plugins.query.partial_result.on_mapping_conflict.enabled, the per-request partial_result field, and the warnings-supported format gate that existed only to protect this feature. A conflicted aggregation once again returns the complete result over every index, which since opensearch-project#5646 pushes down as a _source script rather than failing. Kept whole: the warnings channel it introduced -- Warning, QueryResponse.warnings, CalcitePlanContext.addWarning/drainWarnings, and the SimpleJsonResponseFormatter plumbing. Nothing produces a warning after this commit; opensearch-project#5807 is the next producer, reporting a search that covered only some of its shards. Note for reviewers: dropping partial_result from TransportPPLQueryRequest changes that request's wire format. The class version-gates nothing and the field was appended the same way in 3.9, so this is symmetric with how it arrived, but it does mean a mixed 3.9/3.10 cluster must not route PPL across versions. Signed-off-by: Kai Huang <[email protected]> * Drop the per-index mapping retention the feature needed getIndexMappings() on OpenSearchIndex and lastIndexMappings on the describe request existed only so the partitioner could see which index mapped a field which way. Nothing reads them now. The deep copy before merging stays: MergeRuleHelper rewrites the accumulated type's properties in place, so a fetched mapping would otherwise stop describing its own index. Its test now asserts that on the fetched mappings directly rather than through the removed accessor. Signed-off-by: Kai Huang <[email protected]> --------- Signed-off-by: Kai Huang <[email protected]> (cherry picked from commit 6d666ba) Signed-off-by: Kai Huang <[email protected]>
…5865) * Remove the opt-in partial-result mode for mapping conflicts The mode (#5657) narrowed an aggregation to the index subset where the group field is aggregatable and labelled the result with a warning. It is being dropped: returning a knowingly incomplete answer to make a query faster is the wrong default to offer, and gating it on a cluster setting, a per-request flag and a response-format check made three moving parts that each had to survive the security plugin's transport-to-worker handoff (#5739, #5743, #5758). Removed: PartialResultAggregatePushdown and its hook in CalciteLogicalIndexScan, plugins.query.partial_result.on_mapping_conflict.enabled, the per-request partial_result field, and the warnings-supported format gate that existed only to protect this feature. A conflicted aggregation once again returns the complete result over every index, which since #5646 pushes down as a _source script rather than failing. Kept whole: the warnings channel it introduced -- Warning, QueryResponse.warnings, CalcitePlanContext.addWarning/drainWarnings, and the SimpleJsonResponseFormatter plumbing. Nothing produces a warning after this commit; #5807 is the next producer, reporting a search that covered only some of its shards. Note for reviewers: dropping partial_result from TransportPPLQueryRequest changes that request's wire format. The class version-gates nothing and the field was appended the same way in 3.9, so this is symmetric with how it arrived, but it does mean a mixed 3.9/3.10 cluster must not route PPL across versions. * Drop the per-index mapping retention the feature needed getIndexMappings() on OpenSearchIndex and lastIndexMappings on the describe request existed only so the partitioner could see which index mapped a field which way. Nothing reads them now. The deep copy before merging stays: MergeRuleHelper rewrites the accumulated type's properties in place, so a fetched mapping would otherwise stop describing its own index. Its test now asserts that on the fetched mappings directly rather than through the removed accessor. --------- (cherry picked from commit 6d666ba) Signed-off-by: Kai Huang <[email protected]>
--------- (cherry picked from commit f48b2b1) Signed-off-by: Kai Huang <[email protected]>
Description
OpenSearch answers a search with HTTP 200 as long as one shard responded.
search.default_allow_partial_resultsdefaults totrue, and the plugin never setsallowPartialSearchResults, so every PPL search inherits it.OpenSearchResponseread onlygetHits()/getAggregations()and discarded_shards, so PPL returned the surviving shards' rows as the whole answer, with no error and no warning (#5687).Reproduced on a two-node cluster over a 4-shard pattern holding 990 documents:
This captures the shard outcome and attaches a
PARTIAL_RESULTwarning through the existing warnings channel (Warning→QueryResponse.warnings→SimpleJsonResponseFormatter), which the Explore warning banner already renders as "Partial results":PARTIAL_RESULThad no producer after #5814, so this reuses it instead of adding a type.Warning.javais unchanged.Points for review
failed: 0and just doesn't add up. AfailedShards > 0check misses it, and that's the most common production shape. Atimed_outresponse is the third shape.skippedandsuccessful, so the invariant istotal = successful + failed + missing. Subtractingskippedagain hides a missing shard behind every skipped one. I measured this on a live cluster:total: 3, successful: 2, skipped: 1with one shard unassigned. Can-match only runs abovepre_filter_shard_size(128), so no IT can reach this case, andShardStatsTestpins the arithmetic to the measured numbers instead.client.searchruns on thesql-backgroundpool, which the warning thread-local can't reach.fetchNextBatchruns on the query thread, the same one that drains warnings, so the stats travel on the response object and get recorded there.max_result_windowquery.buildResultSetdrained warnings after the timewrap block, whosefinallyclears the same thread-local, so every timewrap query lost its warnings. It drains first now.Split
As @dai-chen asked, this PR now carries only the warning. The index-pruning fix for #5808 moved to #5819, stacked on this one. Without it, a query with request-level time bounds can still prune an unreachable index before the search runs, so this warning won't fire on that path until #5819 lands.
Testing
The fixture is an index whose shard can never be allocated (an allocation filter naming a node that doesn't exist), next to a healthy index in the same pattern. That gives
total: 2, successful: 1, failed: 0deterministically, with no node manipulation. The unassignable index is dropped between tests so no other class inherits a red cluster.ShardStatsTest(11) andBackgroundSearchScannerTest(+3)CalcitePartialResultOnShardFailureIT(4): count and row queries warn; complete results don'tShardFailureWarningSecurityIT(2): the warning survives the security transport-to-worker handoff for an index-scoped role ([AUTOCUT] Integration Test Failed for sql-3.9.0 #5739); a complete result carries none.integTestWithSecurityonly runsorg.opensearch.sql.security.*, hence the separate class.Also confirmed against a deployed build: 990 with both nodes up, 750 with one stopped, and the 750 now carries the warning.
Scope
Calcite path only, where the warnings channel is wired. Left for follow-ups:
QueryResponsewithout warnings;allow_partial_search_results.Related Issues
Resolves #5687
Check List
docs/user/ppl/interfaces/protocol.mdgains a Warnings section).warningsarray already exists in the response contract.--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.