Skip to content

feat: execute Sirius Substrait reads through Flight - #26981

Merged
mergify[bot] merged 21 commits into
matrixorigin:mainfrom
aunjgr:agent/26154-tpch-sidecar-e2e
Aug 13, 2026
Merged

mergify[bot] merged 21 commits into
matrixorigin:mainfrom
aunjgr:agent/26154-tpch-sidecar-e2e

Conversation

@aunjgr

@aunjgr aunjgr commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #26158

Part of #26154.

What this PR does / why we need it:

Completes the MatrixOne half of the opt-in Sirius Substrait execution path:

  • exports the complete canonical TPC-H Q1-Q22 logical-plan family, including cost-based right outer/semi/anti join orientations, with exact function/type capability admission;
  • admits persistent TAE snapshot reads before compileScope, binds durable GC-protected TaeRead leases, and serves them over the existing strict mTLS resolver;
  • negotiates the exact protocol-v2 capability document and prepares idempotent, single-use Arrow Flight tickets;
  • streams one bounded Arrow IPC batch at a time into MatrixOne vectors and the existing synchronous result writer, without the legacy JSON/MysqlResultSet.Data path;
  • cancels and joins sidecar execution before releasing read leases on every failure, cancellation, panic, reuse, and CN shutdown path; and
  • falls back to native execution only before visibility and only when sidecar quiescence is known.

The runtime is disabled by default and fails closed unless the CN is supplied a replayed, GC-protected lease manager and a durable resolve auditor.

Validation:

  • mo-cgo-test -count=1 ./pkg/sql/compile/sidecarflight ./pkg/sql/compile ./pkg/cnservice ./pkg/frontend ./pkg/sql/plan/substrait
  • mo-cgo-test -race -count=1 -timeout=120s ./pkg/sql/compile/sidecarflight ./pkg/sql/plan/substrait
  • make err-check (production errors use moerr and retain wrapped-cause identity)
  • no github.com/apache/arrow-go or github.com/apache/arrow/go dependency
  • all 22 canonical TPC-H query plans export and deterministically serialize under the negotiated capability hash

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@aunjgr

aunjgr commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both remaining blockers at head 817535452a.

  1. createCompile now attaches CompilePlanMarkKey first, then derives the optional Sirius child context from that counter-bearing request context. The selected marker is kept out of execCtx.reqCtx, so a hinted statement cannot contaminate a later unhinted sibling. TestCompileStatementContextsPreserveCounterWithoutLeakingSelection proves counter visibility on selected and native compilation and the selected-to-native transition.

  2. Hinted prepared executions now bypass a cached native TP topology while retaining that cache under PrepareStmt ownership. Both binary COM_STMT_EXECUTE and text EXECUTE paths rebuild through createCompile, and repeated executions keep doing so rather than silently reverting to the cached native compile. TestInitExecuteStmtParamBypassesCachedTopologyForPreparedSiriusExecution covers both protocols and two successive executions.

The requested deep review also found and fixed two independent exporter closure defects:

  • aggregate nodes with a pushed ProjectList now report the projected width, matching the emitted Substrait relation;
  • unprojected LEFT/RIGHT join result contracts now mark only the null-extended side nullable, preventing Flight schema mismatches.

Additional validation after confirming newest upstream/main is merged:

  • full frontend, compile, cnservice, sidecarflight, and substrait suites;
  • Substrait TPC-H Q1-Q22 export coverage;
  • full sidecarflight and substrait race suites;
  • affected frontend regressions and CN/compile Sirius lifecycle tests under race with -count=100;
  • affected-package build, vet, make err-check, formatting, and diff checks.

No inline review conversations exist on this PR; both change requests were top-level reviews.

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review completed on exact head 2f2587eab0b88f499eb3f7b72e4e4aac16bc1ddb, including all prior review history and the later admission-lifecycle hardening. The two blockers from head 0494c82bc218 are closed: compile contexts retain CompilePlanMarkKey without leaking SIDECAR selection into sibling statements, and hinted binary/text prepared executions bypass the cached native topology across repeated reuse. I also re-audited cancellation/quiescence, retryable lease release, replay ownership, deadline/TTL ordering, forced resolver shutdown, and the new post-admission build-failure recovery; no remaining blocking Q1-Q3 path was confirmed. Focused frontend/compile/Flight/Substrait regressions passed, and the full Flight plus Substrait suites passed under the race detector.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review completed on exact head 2dd6cca170b85a8af70ce409b4e62cb3fdda550b. Since the previously approved head, the only feature-side change is the TLS startup-test timeout correction; the rest is a merge of current main. I re-audited the previously blocking ownership paths: ambiguous prepare and post-run cancellation retain retryable cleanup ownership, lease release remains retryable until full completion, DoGet is deadline-bounded, replay survives runtime shutdown, the selector is statement-scoped, compile counters are preserved, and hinted prepared executions bypass stale cached topology. No new blocking Q1-Q3 path was confirmed.

The affected Flight, Substrait, compile, frontend, and CN package suites passed locally. The critical cancellation/reconciliation/replay, statement isolation/prepared execution, and TLS startup cleanup regressions also passed 100 iterations under the race detector.

@mergify

mergify Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-12 16:17 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in-place
  • 🚫 Left the queue — 2026-08-12 18:35 UTC · at 6605bcfc20e57b9537d142339a109f08c1ed1ed4

This pull request spent 2 hours 17 minutes 21 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

Reason

The merge conditions cannot be satisfied due to failing checks

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify

mergify Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-13 18:20 UTC · Rule: main · triggered by @aunjgr with the merge queue checkbox
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-08-13 18:21 UTC · at cc197a3b919493d639ffd1ef7b5137de830e3b9d · squash

This pull request spent 51 seconds in the queue, including 3 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)

This branch was previously deployed

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

Labels

kind/feature size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants