Skip to content

fix: support Sirius offload for system account - #27409

Merged
mergify[bot] merged 7 commits into
matrixorigin:mainfrom
aunjgr:fix/sirius-system-account
Aug 20, 2026
Merged

mergify[bot] merged 7 commits into
matrixorigin:mainfrom
aunjgr:fix/sirius-system-account

Conversation

@aunjgr

@aunjgr aunjgr commented Aug 20, 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 #26154

What this PR does / why we need it:

The system account has the valid MatrixOne account ID 0, but the Sirius protocol treated zero as a missing identity and silently compiled hinted queries locally. This PR distinguishes field presence from value across admission, TaeRead, Flight, replay, manifests, and resolver matching while keeping absent identities fail-closed.

It also closes production-path blockers exposed after the account gate:

  • source database identity from the canonical TableDef.DbId used by ordinary plans
  • validate optimizer-projected columns against the live schema by column ID/sequence/version
  • accept nullable Arrow metadata for a non-null MO output only while rejecting any actual null batch values
  • canonicalize byte-preserving MatrixOne CHAR values to Substrait VARCHAR for scans, literals, comparison/LIKE/substring/IN, and Arrow result decoding
  • keep width-sensitive string casts fail-closed: CHAR casts and finite narrowing VARCHAR(n) casts are ineligible because Sirius/DuckDB does not enforce MatrixOne truncation/error semantics; only unbounded or widening VARCHAR coercions remain admitted, preserving the canonical TPC-H plans
  • bump Flight to v3 and TaeRead to v2

Validation after merging newest main:

  • go list, go build, and go vet for pkg/sql/plan/substrait
  • complete pkg/sql/plan/substrait suite and Test_strToStr_StrictStringWidth in pkg/sql/plan/function
  • counterexample: unfixed export admitted both CAST(abcd AS CHAR(3)) and VARCHAR(3); fixed export declines both while all 22 canonical TPC-H plans still export\n- prior scope validation retained: pkg/sql/compile/sidecarflight, pkg/vm/engine/disttae/sidecar, and pkg/sql/compile tests; real sys:dump FIFO-held E2E completed six distinct SF10 SUM queries through GPU_TAE_SCAN over 59,986,052 rows\n

@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 →

@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.

Reviewed exact head 8f102ea. No blocking issues found. I verified zero-valued account identity is preserved distinctly from field absence across TaeRead/Flight encoding, durable lease replay/grouping, resolver matching, manifests, and cancellation identity; also checked canonical database identity, projected-column validation against the live schema, and Arrow null enforcement. Validation: full tests for substrait, sidecarflight, disttae/sidecar, and sql/compile; full race tests for the first three plus focused Sirius compile races; go vet for all four packages; diff check clean.

@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.

Reviewed exact head dd712e795f7734b90400941a8be396525ab32274.

[P1] Keep width-sensitive CHAR casts fail-closed

Adding T_char to tpchCastType makes a real bound query such as select cast(n_name as char(3)) from tpch.nation pass Export. MatrixOne's string cast contract truncates an over-width value ("abcd" becomes "abc" for CHAR(3)), while the Sirius/DuckDB representation used here lowers the target to VARCHAR; DuckDB does not enforce the declared VARCHAR(n)/CHAR(n) width (cast('abcd' as varchar(3)) and cast('abcd' as char(3)) both remain "abcd"). The Flight decoder then labels that untruncated payload as the expected MO CHAR(3), so an offloaded query can silently return a value different from local execution.

Please restrict CHAR admission to the byte-preserving cases (scan/literal/comparison/LIKE/etc.) and keep casts whose target has a width-dependent MO contract ineligible until Sirius explicitly implements and verifies the same truncation/error behavior. Add a differential regression with an input longer than the target width. The PR description also needs updating: the current head no longer matches its statement that CHAR remains fail-closed.

Validation performed: full tests for pkg/sql/plan/substrait, pkg/sql/compile/sidecarflight, and pkg/vm/engine/disttae/sidecar; focused bound-plan counterexample above; direct DuckDB width check; git diff --check.

@gouhongshen gouhongshen 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.

Codex automated review

Reviewed exact head dd712e7 independently; no new blocking or non-blocking findings beyond the open review thread. Loaded existing state first: aptend approved an earlier head (8f102ea, pre-CHAR commit); XuPeng-SH has an unaddressed CHANGES_REQUESTED on this exact head for the width-sensitive CHAR cast divergence (MO truncates over-width CHAR casts via strToStr in pkg/sql/plan/function/func_cast.go:7714 while the Sirius/DuckDB side does not enforce declared width). That finding is valid and remains between him and the author; I did not duplicate it. One note for the pending fix: the same width-enforcement gap predates this PR for VARCHAR cast targets (origin/main tpchCastType already admits T_varchar, and strToStr truncates T_char/T_varchar identically), so restricting only T_char would leave the identical divergence reachable via CAST(... AS VARCHAR(n)); char and varchar cast targets should be handled uniformly.

Verified from code:

  1. Database identity fix is real and necessary: neither production Resolve (pkg/frontend/compiler_context.go:632, pkg/sql/compile/sql_executor_context.go:384) ever sets ObjRef.Db, so the old ObjRef.Db<=0 check rejected every genuine plan as malformed; TableDef.DbId is the canonical catalog identity (pkg/vm/engine/disttae/txn_table.go:1598) and is now cross-checked against the live relation (provider.go).
  2. Account-0 presence is handled distinctly from absence end-to-end: Flight AccountID became proto-optional (wire presence exercised with accountID=0 through the stub server's nil check), TaeRead field 5 presence is mandatory (field-stripping test asserts 'missing TaeRead field'), executionIdempotencyKey hashes a fixed-width LE account so account 0 cannot collide with other accounts, and resolver matching/grouping/manifests all compare values directly. Flight v3 / TaeRead v2 / capability-hash bumps keep mixed-generation pairs fail-closed.
  3. Arrow nullability relaxation is safe: schema-level negotiation no longer rejects nullable metadata, but decodeColumn rejects any actual nulls when MO expects NotNullable, and an absent validity buffer is only tolerated when nullCount==0.
  4. projectPlannedColumns validates planned columns by ColId+Seqnum with duplicate rejection and preserves the CanonicalSchema byte-equality gate; the manifest intentionally still describes the full physical schema while read.Schema is the logical projection.
  5. semanticNotNullable only strengthens concrete non-NULL literals (a sound value fact); the equality gate against planner annotations stays fail-closed, and DIV/MOD remain conservative inside DeduceNotNullable itself.
  6. CHAR outside casts is byte-preserving: MO stores/casts CHAR without space padding (strToStr), so scan/comparison/LIKE/starts_with/substring/IN produce identical bytes locally and offloaded.

Validation: ran full test suites for pkg/sql/plan/substrait, pkg/sql/compile/sidecarflight, pkg/vm/engine/disttae/sidecar, and the Sirius tests in pkg/sql/compile on this head — all pass.

@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-reviewed the complete diff at exact head a5ba2b18f051be2ae28afeca9fe630e33c9ed707 (merge-base 2073cfdfa566cf41e591e24a108f3ce22065f927). APPROVED.

The prior width-sensitive string-cast blocker is closed. CHAR targets and finite narrowing VARCHAR targets now fail closed, while only byte-preserving VARCHAR widening/unbounded coercions remain eligible. The public bound-plan regressions cover over-width CHAR(3) and VARCHAR(3), and an independent derived-expression probe (substring(...) to VARCHAR(3)) also remained ineligible.

I rechecked the surrounding closure: account ID zero is represented as a required present varint across TaeRead/Flight v3 instead of being treated as absent; database/table/schema identity is revalidated against the live relation; optimizer-projected columns are resolved by stable column ID/sequence; nullable Arrow metadata may describe a non-null MO result but any actual null is still rejected during decode. The wire/version changes remain fail-closed for old or missing fields, and no new unbounded resource/wait path is introduced.

Exact-head validation passed for the complete pkg/sql/plan/substrait, pkg/sql/compile/sidecarflight, and pkg/vm/engine/disttae/sidecar packages, plus the focused cast matrix for 10 consecutive runs. git diff --check is clean; the PR remains mergeable with all substantive CI checks successful. No blocking findings remain.

@mergify mergify Bot added the queued label Aug 20, 2026
@mergify

mergify Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-20 22:40 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-08-20 23:29 UTC · at 2c86e95f452584379a7ec24ff1c83cf294204311 · squash

This pull request spent 49 minutes 26 seconds in the queue, including 48 minutes 39 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)

@mergify
mergify Bot merged commit 0543eb9 into matrixorigin:main Aug 20, 2026
26 of 27 checks passed
@mergify mergify Bot removed the queued label Aug 20, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
The system account has the valid MatrixOne account ID `0`, but the Sirius protocol treated zero as a missing identity and silently compiled hinted queries locally. This PR distinguishes field presence from value across admission, TaeRead, Flight, replay, manifests, and resolver matching while keeping absent identities fail-closed.

It also closes production-path blockers exposed after the account gate:

- source database identity from the canonical `TableDef.DbId` used by ordinary plans
- validate optimizer-projected columns against the live schema by column ID/sequence/version
- accept nullable Arrow metadata for a non-null MO output only while rejecting any actual null batch values
- canonicalize byte-preserving MatrixOne `CHAR` values to Substrait `VARCHAR` for scans, literals, comparison/LIKE/substring/IN, and Arrow result decoding
- keep width-sensitive string casts fail-closed: `CHAR` casts and finite narrowing `VARCHAR(n)` casts are ineligible because Sirius/DuckDB does not enforce MatrixOne truncation/error semantics; only unbounded or widening `VARCHAR` coercions remain admitted, preserving the canonical TPC-H plans
- bump Flight to v3 and TaeRead to v2

Validation after merging newest `main`:

- `go list`, `go build`, and `go vet` for `pkg/sql/plan/substrait`
- complete `pkg/sql/plan/substrait` suite and `Test_strToStr_StrictStringWidth` in `pkg/sql/plan/function`
- counterexample: unfixed export admitted both `CAST(abcd AS CHAR(3))` and `VARCHAR(3)`; fixed export declines both while all 22 canonical TPC-H plans still export\n- prior scope validation retained: `pkg/sql/compile/sidecarflight`, `pkg/vm/engine/disttae/sidecar`, and `pkg/sql/compile` tests; real `sys:dump` FIFO-held E2E completed six distinct SF10 SUM queries through `GPU_TAE_SCAN` over 59,986,052 rows\n

Approved by: @aptend, @XuPeng-SH, @gouhongshen
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
The system account has the valid MatrixOne account ID `0`, but the Sirius protocol treated zero as a missing identity and silently compiled hinted queries locally. This PR distinguishes field presence from value across admission, TaeRead, Flight, replay, manifests, and resolver matching while keeping absent identities fail-closed.

It also closes production-path blockers exposed after the account gate:

- source database identity from the canonical `TableDef.DbId` used by ordinary plans
- validate optimizer-projected columns against the live schema by column ID/sequence/version
- accept nullable Arrow metadata for a non-null MO output only while rejecting any actual null batch values
- canonicalize byte-preserving MatrixOne `CHAR` values to Substrait `VARCHAR` for scans, literals, comparison/LIKE/substring/IN, and Arrow result decoding
- keep width-sensitive string casts fail-closed: `CHAR` casts and finite narrowing `VARCHAR(n)` casts are ineligible because Sirius/DuckDB does not enforce MatrixOne truncation/error semantics; only unbounded or widening `VARCHAR` coercions remain admitted, preserving the canonical TPC-H plans
- bump Flight to v3 and TaeRead to v2

Validation after merging newest `main`:

- `go list`, `go build`, and `go vet` for `pkg/sql/plan/substrait`
- complete `pkg/sql/plan/substrait` suite and `Test_strToStr_StrictStringWidth` in `pkg/sql/plan/function`
- counterexample: unfixed export admitted both `CAST(abcd AS CHAR(3))` and `VARCHAR(3)`; fixed export declines both while all 22 canonical TPC-H plans still export\n- prior scope validation retained: `pkg/sql/compile/sidecarflight`, `pkg/vm/engine/disttae/sidecar`, and `pkg/sql/compile` tests; real `sys:dump` FIFO-held E2E completed six distinct SF10 SUM queries through `GPU_TAE_SCAN` over 59,986,052 rows\n

Approved by: @aptend, @XuPeng-SH, @gouhongshen
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
The system account has the valid MatrixOne account ID `0`, but the Sirius protocol treated zero as a missing identity and silently compiled hinted queries locally. This PR distinguishes field presence from value across admission, TaeRead, Flight, replay, manifests, and resolver matching while keeping absent identities fail-closed.

It also closes production-path blockers exposed after the account gate:

- source database identity from the canonical `TableDef.DbId` used by ordinary plans
- validate optimizer-projected columns against the live schema by column ID/sequence/version
- accept nullable Arrow metadata for a non-null MO output only while rejecting any actual null batch values
- canonicalize byte-preserving MatrixOne `CHAR` values to Substrait `VARCHAR` for scans, literals, comparison/LIKE/substring/IN, and Arrow result decoding
- keep width-sensitive string casts fail-closed: `CHAR` casts and finite narrowing `VARCHAR(n)` casts are ineligible because Sirius/DuckDB does not enforce MatrixOne truncation/error semantics; only unbounded or widening `VARCHAR` coercions remain admitted, preserving the canonical TPC-H plans
- bump Flight to v3 and TaeRead to v2

Validation after merging newest `main`:

- `go list`, `go build`, and `go vet` for `pkg/sql/plan/substrait`
- complete `pkg/sql/plan/substrait` suite and `Test_strToStr_StrictStringWidth` in `pkg/sql/plan/function`
- counterexample: unfixed export admitted both `CAST(abcd AS CHAR(3))` and `VARCHAR(3)`; fixed export declines both while all 22 canonical TPC-H plans still export\n- prior scope validation retained: `pkg/sql/compile/sidecarflight`, `pkg/vm/engine/disttae/sidecar`, and `pkg/sql/compile` tests; real `sys:dump` FIFO-held E2E completed six distinct SF10 SUM queries through `GPU_TAE_SCAN` over 59,986,052 rows\n

Approved by: @aptend, @XuPeng-SH, @gouhongshen

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/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants