Skip to content

[AUTOCUT] Integration Test Failed for sql-3.9.0 #5739

Closed

Activity

  1. RyanL1997 commented on Sep 2, 2026

    @RyanL1997
    Collaborator

    @ryan-gh-bot can you do a rca of the above failure?

  2. ryan-gh-bot commented on Sep 2, 2026

    @ryan-gh-bot
    Contributor

    Working on /@triage (invoked by @RyanL1997) — posting result when done.

  3. ryan-gh-bot commented on Sep 2, 2026

    @ryan-gh-bot
    Contributor

    [RCA] CalcitePartialResultOnMappingConflictIT (new in PR #5657) fails only in the with-security config because the partial-result path is not engaged there

    All seven failures in the 3.9.0 integ-test AUTOCUT are in a single new test class introduced by PR #5657 (partial-result mode for text/keyword mapping conflicts). The without-security config passes; only with-security fails, and the assertion pattern (unnarrowed row counts, missing warnings field) matches what happens when tryPartialResultAggregate bails out and the query falls through to the normal complete-result path. The proximate cause is inside PR #5657 itself; the feature was not exercised end-to-end with the security plugin.

    Environment

    Suspected location

    Analysis

    CalcitePartialResultOnMappingConflictIT was added by PR #5657 and did not exist before this commit. The seven failing test methods all set plugins.calcite.partial_result.on_mapping_conflict.enabled=true, then assert (a) the result narrows to the aggregatable (keyword) index subset only, and (b) the response carries a PARTIAL_RESULT entry in a warnings array. In the CI stderr the observed responses do neither:

    • Six assertEquals failures on datarows.length() with actual = expected + 1 or expected + 2 (e.g., expected:<2> but was:<3> for partialResultOnReturnsKeywordSubsetWithWarning at L267). Those extra rows are exactly the buckets contributed by the text indices that partial mode is supposed to exclude — so the query is returning the same rows as the partialResultOffReturnsCompleteResultWithoutWarning case (L246-L254), which is the complete-path result.
    • One JSONObject["warnings"] not found in partialResultWarningTruncatesLargeExcludedList at L415 — the response has no warnings array at all.

    Both symptoms have one code path: tryPartialResultAggregate returned null, so pushDownAggregate proceeded down the normal branch (in-memory _source script per PR #5646), which returns every index's data and never records a warning. The method has only three ways to return null short of running the partitioner:

    1. !QueryContext.isPartialResultEnabled(...) at L513 — reads a per-request override from Log4j ThreadContext and, if unset, falls back to the cluster setting. The tests set the persistent cluster setting via setPartialResult(true) and never populate the override, so this gate should return true regardless of thread propagation. Not a candidate.
    2. !QueryContext.isWarningsSupported() at L517 — reads only from Log4j ThreadContext, with no cluster-setting fallback (QueryContext.java#L109-L111). Default when unset is false → this gate then bails out.
    3. PartialResultAggregatePushdown.plan(...) returns null — this depends on the fetched per-index mappings and wouldn't differ between security configs on identically-provisioned test indices.

    Path (2) is the fit. QueryContext.setWarningsSupported(true) is invoked exactly once, on the transport thread inside TransportPPLQueryAction.doExecute at L199. The value is stored in Log4j ThreadContext — a plain ThreadLocal<Map<String, String>> with no propagation across executor boundaries. OpenSearchQueryManager.schedule does snapshot the Log4j ThreadContext map before handing off to the sql-worker pool, so under normal routing the flag survives the handoff. Under the security plugin, however, the transport action is invoked from inside a TransportInterceptor that operates in an OpenSearch ThreadContext.stashContext() / restore scope — that scope preserves OpenSearch's transient/header ThreadContext, but is unrelated to Log4j's ThreadContext. Concretely, the security interceptor may:

    • run doExecute on a fresh worker thread whose Log4j ThreadContext map is empty from a prior clear (clearRequestScopedState explicitly sets warnings_supported=false), and/or
    • reset the log ThreadContext across the async wrap, leaving warnings_supported=false visible to tryPartialResultAggregate even though setWarningsSupported(true) was called upstream.

    Either way, isWarningsSupported() returns false on the planning thread and the partial-result branch is skipped, exactly matching every failure.

    The without-security config uses a plain transport chain, setWarningsSupported(true) runs on the same thread that eventually invokes pushDownAggregate (or OpenSearchQueryManager.schedule snapshots it in time), so the gate passes there and the tests pass. Same code, different threading — hence the security-only split.

    Evidence

    • Failing tests + assertion messages (fetched from CI stderr for linux/x64/tar run 11545, file):

      • partialResultOnHandlesMultiFieldExpressionGroupKey L352 — expected:<2> but was:<4>
      • partialResultOnHandlesNestedDottedField L303 — expected:<2> but was:<3>
      • partialResultWarningTruncatesLargeExcludedList L415 — JSONObject["warnings"] not found
      • partialResultOnHandlesEvalDerivedGroupKey L327 — expected:<2> but was:<3>
      • partialResultOnReturnsKeywordSubsetWithWarning L267 — expected:<2> but was:<3>
      • partialResultKeepsNumericExcludesText L376 — expected:<2> but was:<4>
      • partialResultKeepsKeywordGroupEvenWhenOutnumbered L398 — expected:<2> but was:<3>

      All observed row counts equal what the complete-result path (partialResult=off) would produce (keyword-index buckets ∪ text-index buckets), matching the "partial path bypassed" hypothesis.

    • Config split: same 3.9.0 build 12182, sql component, run 11545 — with-security FAIL, without-security PASS. The test class is the sole failing suite; total run 7257 completed, 7 failed, 232 skipped.

    • Regression check: The test class and every symbol its bodies reference (Warning, PARTIAL_RESULT, tryPartialResultAggregate, PartialResultAggregatePushdown, setWarningsSupported, setPartialResultOverride) are all newly introduced by 18c39e381 (merged Sep 1). There is no prior working reference on main. So this is a first-appearance defect in the newly-landed feature, not a regression against an older release; the failure appeared the first time this test class ran against a with-security distribution.

    • Live verification: not attempted — reproducing the with-security path requires a distribution build with the security plugin installed, which is out of scope for the standard :opensearch-sql-plugin:run local server described in the tenant's reproduce guide.

    Confidence: High
    Three independent signals point at the same hypothesis: (a) the source code has exactly one bail-out at CalciteLogicalIndexScan.java#L517 whose default-when-missing behavior exactly matches the observed responses; (c) the failure is scoped to the commit that first introduced the code; and the with-security-only split is exactly the shape you get when a ThreadLocal gate is dropped by an executor handoff that the security plugin inserts and the plain path does not. The remaining uncertainty is which specific security-plugin thread transition drops the Log4j ThreadContext, not whether the drop is the cause.

    Next steps

    • Reproduce locally in integ-test with security enabled and log QueryContext.isWarningsSupported() at CalciteLogicalIndexScan.java#L517 to confirm the flag is false at planning time. If yes, the fix is to move warnings_supported off Log4j ThreadContext — e.g., carry it on CalcitePlanContext (already threaded through planning and used for warnings) or on the request/plan itself so it isn't tied to a thread-local. That parallels the treatment of the collected warnings, which the same commit already stores on CalcitePlanContext for the same reason.
    • Unverified suggestion: the same threading concern applies to the partial_result_override per-request override at TransportPPLQueryAction.java#L201. Under with-security, an API-body partial_result: false sent from Dashboards could similarly fail to reach the planner and defer to the cluster setting instead. The AUTOCUT tests do not exercise this path (they set the cluster setting), so it would not be caught by the current suite. Worth covering when the primary fix lands.
    • Add a with-security variant of the new IT (or run the existing one under the secure test cluster) so this class of "feature depends on Log4j ThreadContext reaching the planner" never regresses silently again.
    • Reporter/maintainer action needed: none — this is a code defect in the just-landed PR Add an opt-in partial-result mode for aggregations on text/keyword mapping conflicts #5657 and can be fixed forward. If a hotfix is desired for 3.9.0, cherry-pick the fix into the 3.9 release branch once written.

    Automated response from @ryan-gh-bot (maintainer-triggered agent). About this agent.

  4. RyanL1997 commented on Sep 2, 2026

    @RyanL1997
    Collaborator

    cc @ahkcs for the above - looks like it is related to #5657

  5. opensearch-ci-bot commented on Sep 4, 2026

    @opensearch-ci-bot
    ContributorAuthor

    Closing the issue as the integration tests for sql passed for version: 3.9.0.

  6. opensearch-ci-bot commented on Sep 7, 2026

    @opensearch-ci-bot
    ContributorAuthor

    Closing the issue as the integration tests for sql passed for version: 3.9.0.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions