Repository navigation
Fix partial-result warnings gate lost across the security thread handoff (#5739) - #5743
Conversation
…off (opensearch-project#5739) isWarningsSupported() was backed by Log4j ThreadContext and set on the transport thread. Under the security plugin the transport->worker handoff drops that ThreadContext, so the gate read false at planning time and tryPartialResultAggregate bailed to the complete result with no warnings -- the release integ-test failed only in the with-security config (without-security passed). Carry warnings-support off the thread-local: PPLQueryRequest -> AbstractPlan -> QueryPlan.execute (runs on the worker thread) -> CalcitePlanContext, which the scan already reads. It is included in CalcitePlanContext's thread-local snapshot so it also survives the planner's own handoff, and is reset per query. Remove the now-dead QueryContext warnings-supported methods. Cross-thread tests in QueryPlanTest prove the flag rides the plan object and survives a config-thread != execute-thread handoff. Signed-off-by: Kai Huang <[email protected]>
PR Reviewer Guide 🔍(Review updated until commit 9180b99)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 9180b99 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit ca22496
Suggestions up to commit 509cc4b
Suggestions up to commit ca22496
|
|
Persistent review updated to latest commit 509cc4b |
509cc4b to
ca22496
Compare
|
Persistent review updated to latest commit ca22496 |
RyanL1997
left a comment
There was a problem hiding this comment.
Since we didnt catch this under the CI with security can we also add these cases under integ-test/src/test/java/org/opensearch/sql/security/?
…ch-project#5739) Per review: the integTestWithSecurity suite only runs org.opensearch.sql.security.*, so the partial-result IT (under calcite/remote) never ran with the security plugin, which is why CI stayed green while the regression shipped. This IT exercises the path under security so CI catches it: a text/keyword mapping-conflict aggregation must return the keyword subset with a PARTIAL_RESULT warning. Verified locally under the secure testcluster -- it passes on this fix and fails on the pre-fix code (expected:<2> but was:<3>: the excluded index's rows leak in and the warning is dropped), so it is a true differential guard. Signed-off-by: Kai Huang <[email protected]>
|
Persistent review updated to latest commit 9180b99 |
Added |
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]>
* 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]>
…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]>
Description
Fixes the
with-security-only integ-test failure in #5739 (https://github.com/opensearch-project/sql/issues/5739#issuecomment-5516921306)(`CalcitePartialResultOnMappingConflictIT`, 7 methods). The partial-result feature was added in #5657; this is a regression in that feature's warning channel under the security plugin.QueryContext.isWarningsSupported()was backed by Log4jThreadContextand set once on the transport thread (TransportPPLQueryAction). The partial-result gate reads it on the planning thread (CalciteLogicalIndexScan.tryPartialResultAggregate). Under the security plugin, the transport→worker handoff does not preserve Log4j'sThreadContext, so the flag readfalseat planning time,tryPartialResultAggregatebailed, and the query returned the complete result with nowarnings— the exact symptom in the failing tests (extra text-index buckets; missingwarnings). It reproduces only in the release distribution's security config;without-securitypassed, which is why the plugin's ownintegTestWithSecurity(which only runsorg.opensearch.sql.security.*, and the partial-result IT lives elsewhere) went green on the original PR.Fix
Carry warnings-support off the thread-local and onto the object graph, so no thread handoff can drop it:
PPLQueryRequest.warningsSupported(set from the response format on the transport thread) →AbstractPlan→QueryPlan.execute()(runs on the worker thread) →CalcitePlanContext.setWarningsSupported(...), which the scan already reads. It's also included inCalcitePlanContext's thread-local snapshot (so it survives the planner's own handoff) and reset per query. The now-deadQueryContextwarnings-supported methods are removed.isPartialResultEnabledwas already resilient (it falls back to the cluster setting), so onlywarningsSupportedneeded this.Testing
QueryPlanTest: two new cross-thread tests prove the flag rides the plan object and is honored when the configuring thread ≠ theexecute()thread (the exact bug class), and that a warnings-unsupported plan resets the flag on a reused pooled worker thread.PartialResultAggregatePushdownTest(19) and:opensearch-sql-plugin:compileJavapass.PartialResultSecurityIT(new, underorg.opensearch.sql.security) exercises the partial-result path with the security plugin installed, so CI'sintegTestWithSecuritynow covers it — closing the gap that let this regression ship (that suite only runsorg.opensearch.sql.security.*, and the feature IT lives undercalcite/remote). Verified locally against the secure testcluster: it passes on this fix and fails on the pre-fix code (expected:<2> but was:<3>— the complete result leaks the excluded index's rows and drops thewarnings), so it is a true differential guard.Check List