Repository navigation
fix: support Sirius offload for system account - #27409
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
aptend
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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:
- 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).
- 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.
- 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.
- 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.
- 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.
- 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
left a comment
There was a problem hiding this comment.
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.
Merge Queue Status
This pull request spent 49 minutes 26 seconds in the queue, including 48 minutes 39 seconds running CI. Required conditions to merge
|
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
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
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
What type of PR is this?
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:
TableDef.DbIdused by ordinary plansCHARvalues to SubstraitVARCHARfor scans, literals, comparison/LIKE/substring/IN, and Arrow result decodingCHARcasts and finite narrowingVARCHAR(n)casts are ineligible because Sirius/DuckDB does not enforce MatrixOne truncation/error semantics; only unbounded or wideningVARCHARcoercions remain admitted, preserving the canonical TPC-H plansValidation after merging newest
main:go list,go build, andgo vetforpkg/sql/plan/substraitpkg/sql/plan/substraitsuite andTest_strToStr_StrictStringWidthinpkg/sql/plan/functionCAST(abcd AS CHAR(3))andVARCHAR(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, andpkg/sql/compiletests; realsys:dumpFIFO-held E2E completed six distinct SF10 SUM queries throughGPU_TAE_SCANover 59,986,052 rows\n