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 <ahkcs@amazon.com>
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 <ahkcs@amazon.com>
|
Persistent review updated to latest commit 9180b99 |
Added |
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