Repository navigation
test: fix transaction, context and resource ownership in UT fixtures - #30670
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? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
|
mo-bot review · Commit: "interrupted" |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-xupeng · review
Commit: 909b988e5d83794e83d7023133583fa461381b05
Assessment: approve
Reviewed the complete three-file test-only delta and its production owners. The changes preserve behavioral assertions while correcting cancellation and fixture cleanup ownership. No actionable defects remain.
Model: gpt-6-astra / xhigh
Session: 01a15209-2c6d-71e2-b8f3-aa17387fa283 · slot 2 · generation 0
Validation:
-
Verified unchanged source, native provenance, and command/source/exit receipts against retained logs. Evidence index: /home/xupeng/.local/state/mo-bot/jobs/78f9d008fa79f1736cdb2cfa/attempt-1/verified-evidence.json.
-
Full publication and Group packages passed in normal mode: 876 and 382 test/subtest nodes respectively.
-
The publication retry test passed 100 repetitions under the race detector.
-
Seven Group test roots passed with an injected 8 GiB disk sample in normal and race modes. Restoring the old fixtures reproduced the expected spill-budget failures.
-
The role-policy test passed normal, race, and two consecutive race iterations sharing one cluster. Injected FailNow after BEGIN produced only the intended failure, with no cleanup assertion failures.
Limitations:
-
The full issues package encountered an unchanged auto-ID DUMP TABLE failure and reached its 600-second runtime bound before the modified role test. Focused role validation completed separately; no full issues-package pass is claimed.
-
Local execution covered Linux amd64 with focused race checks. Frozen substantive CI remained pending/skipped; standalone linked-issue bodies and raw author validation logs were unavailable.
|
mo-bot review · Commit: Review completed. Read the assessment. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 81887fa847947b499586158cb7d0a57b2ca924e0
Assessment: approve
Reviewed the complete four-file test-only delta and its production owners. The changes correct context, budget and cleanup ownership, and narrowly recover valid stale-snapshot aborts without weakening fixed-snapshot rejection. The design is coherent, preserves behavioral assertions and adds no production runtime cost. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Full normal suites passed: embed 493 test/subtest nodes, publication 876, Group 382 and issues 1,692.
-
CHECK namespace tests passed under race, including real intervening-commit recovery and cancellation controls. Publication passed 100 race repetitions; role refresh passed two same-process race repetitions.
-
Complete Group passed under race with an injected 8 GiB disk sample. Seven corrected roots passed normally under that sample; baseline fixtures reproduced eleven failing nodes with one-byte spill limits.
-
Injected FailNow after BEGIN produced only the intentional failure; rollback, tenant-pool closure and account-deletion assertions succeeded.
-
Verified unchanged source, matching native inputs, command/source/exit receipts and retained logs. Evidence index: /home/xupeng/.local/state/mo-bot/jobs/63ea81a6f106becb834a8f7e/attempt-1/verified-evidence.json.
Limitations:
-
Local validation used Linux amd64 and Go 1.27.1. Race coverage outside Group was focused; frozen substantive CI remained pending.
-
Two unchanged embed tests skipped: external-MySQL CDC and CN restart.
-
Standalone linked-issue bodies and referenced prior validation artifacts were unavailable. Fresh validation covered the changed contracts.
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-xupeng · review
Commit: 81887fa847947b499586158cb7d0a57b2ca924e0
Assessment: approve
Reviewed the complete four-file delta, ownership paths, failure handling, tests and supplied comments. The fixture fixes preserve the original behavioral assertions. No actionable defects remain.
Model: gpt-6-astra / xhigh
Session: 01a15209-2c6d-71e2-b8f3-aa17387fa283 · slot 2 · generation 0
Validation:
-
Current namespace and recovery-control tests passed: 29 test nodes, 178.478s. Namespace race validation passed: 20 nodes, 179.452s. Receipts: checks/1792504028311993781-3.json and checks/1792504038258792320-3.json.
-
Both runs demonstrated the exact stale-snapshot error followed by a different transaction ID and the expected CHECK violation on the same connection.
-
Independently reconciled retained evidence for the three unchanged fixture files: publication and Group package passes, publication race count=100, forced-low-disk normal/race checks and failing baseline controls, plus role-refresh normal/race/reuse and failure-cleanup checks.
-
Isolation preflight, native provenance verification and diff checks passed. Verified the current-file overlay against the otherwise identical retained checkout; source remained unchanged. Commands, fingerprints, receipts and log hashes are indexed in /home/xupeng/.local/state/mo-bot/jobs/02b2e8ecf9105a30b4969cff/attempt-1/verified-evidence.json.
Limitations:
-
Current full embed and issues suites were not rerun. The retained full issues run encountered an unrelated DUMP TABLE failure and timed out; it is not counted as a package pass.
-
Local execution covered Linux amd64 CPU. Substantive frozen CI was pending or skipped; unretained author execution reports were not treated as verified passes.
-
Standalone linked-issue bodies were not supplied; their stated contracts were assessed from the frozen PR description and source.
Add an **explicit, opt-in** derived-View planning entry for SELECT, CTAS, and supported text/typed PREPARE statements. Persisted View columns no longer determine admission, binding, or CTAS metadata/default provenance in this path. - Bind real executable base-table subtrees; never reuse Describe's synthetic metadata-only memo scans for execution. Share the binder's placeholder classification with early numeric source collection, so unqualified DUAL is a value-only source while qualified `db.dual` remains a protected physical root. - Preserve explicit names, null-extension, existing CTAS default policy, publisher/snapshot identity, and transitive dependencies in `CatalogDependencies` / `Prepare.Schemas`. CTAS source binding inherits the caller's effective snapshot, while target existence checks and existing DDL invalidation rules remain unchanged. Reuse existing cache/reprepare validators rather than introducing durable invalidation. - Authorize root visibility before catalog probes, including PREPARE's pre-binding numeric metadata lookups. Authorization and resolution share the binding context's actual snapshot; skip optional probes when the context or a source/CTE time hint is unresolved. Preserve the first denial through optional inference without caching successful grants or exposing the private derivation marker to authorization SQL; keep final statement/plan execution authorization with the caller. - Deep-copy publisher identity in `DeepCopyObjectRef` and attach the effective publisher account to executable physical-table references and dependency copies; preserve request/plan ownership across cancellation and Close. - Keep ordinary cross-database intermediate Views distinct from resolved subscription entries: preserve dependency account evidence without inventing a View entry alias. Scope PREPARE's metadata-name probes to the View/CTE binding database, not the statement owner's default database. Numeric CTE references retain their declaration namespace; recursive projection/scalar probes and the propagation queue use the normal binder's `findCTE`, including ancestor declaration masks, instead of bypassing visibility through a flat numeric index. Normal and numeric registration share declaration-order construction, and target keys respect the binding comparison mode rather than unconditionally folding case. - Isolate trusted planner and subscription-metadata SQL from the outer derivation marker, including cloned historical transactions, so these catalog reads do not become user roots. Preserve cancellation, transaction/snapshot identity, and direct user-query authorization. Restore borrowed compiler snapshots on success/error/panic at both the CTE binding phase and request boundary; propagate the original panic without contaminating subsequent planning. - Extend unit and existing native fixtures for stale physical columns, nested views, CTAS, PREPARE/cache identity changes, subscriptions/history/RBAC, and upstream correlated-query main-output compatibility. Implementation and consumer audit: [S3 design](https://github.com/ck89119/matrixone/blob/issue-29438-main/docs/design/CLAUDE_20261018-view-s3-consumers.md). ### Scope / rollout **Default SQL, PREPARE, and cursor routing is unchanged.** The opt-in helper is not a replacement for frontend parameter normalization, retry/reprepare routing, stats/trace, final authorization, or protocol sending. This PR does not claim default binary/cursor activation or completion of S5/S6/S8/S9 validation and rollout gates. No background refresh, persistent freshness mechanism, cross-request cache, or independent CTAS semantics are added. ### Validation Validated after merging upstream `main@76e152a`, using Go **1.27.1**, darwin/arm64, and the repository CGo wrapper: - Focused View-schema/metadata/description UTs; complete `pkg/sql/plan` and `pkg/frontend` owning packages in normal mode; affected View-schema and snapshot/internal-SQL tests with `-race`. - CI run 39399062579 failed in `TestCheckConstraintNamespace/repeatable_read_rejects_a_catalog_commit_after_its_snapshot`: the old SI rejection succeeded, but the subsequent fresh-SI positive assertion encountered another valid namespace abort. Merged upstream #30670 rather than maintaining a duplicate fix. The exact failing subtest and complete CHECK namespace/recovery group pass locally with CI's `matrixone_test`, `-short`, and `-race` flags. The original fixed-snapshot rejection and terminal-error checks remain intact; local darwin/arm64 evidence is not a claim that a new full Linux CI run has passed. - Pseudo-table matrix: 32 cases across ordinary/direct/text/typed planning, no-FROM, DUAL case/quoting/aliases/CTE shadowing and qualified physical controls. Native coverage actually executes all eight no-FROM/DUAL mode combinations, returns one constant row, and rejects all four qualified-DUAL controls without weakening the authorizer. - Snapshot authorization/resolution matrix: 80 cases across ordinary/direct/text/typed entry points, historical-only/current-only policies, SELECT/CTAS, CTE SUM/AVG/chains and time hints; unknown binding scope performs no probe. Historical source dependencies are checked for current-domain contamination; CTAS target/catalog checks and its existing account-wide DDL marker explicitly retain their original semantics. Three additional CTE-scope cases verify inherited/declaration namespaces and explicit snapshot precedence. Native historical-only authorization covers SELECT, CTE SUM and CTAS planning in all four modes, retaining the pre-ALTER one-column schema rather than the current two-column schema. - CTE lexical-scope matrix: 44 cases across four modes, including later declarations, ancestor masks, shadowing, qualified controls, chains, body-local WITH and scalar consumers. No unused View may be authorized, resolved or captured as a dependency. Eight native executions cover shadowing and declaration order, producing SUM(id)=3 while permitting only the actually referenced View. - Case-sensitive roots: 28 cases across four modes, physical/quoted/qualified/scalar roots, actual CTE/parser-alias controls and lower_case_table_names=1 rejection controls. Eight duplicate-CTE cases reject without authorization/catalog probes. - Snapshot unwind/reuse: 16 cases across four modes, error/panic and nil/non-nil caller snapshots. Inject failure only after CTE binding publishes the historical domain, verify exact restoration and panic propagation, then authorize/resolve/plan the next root on the same request in the caller's original domain with no retained leases. - Explicit correlated-View main-output/deep-copy regression. Ordinary SELECT, direct prepared planning, text PREPARE, and typed PREPARE all reject with zero relation/database/subscription probes, preserve a one-shot denial, recover on a later planning call, and never enter a blocking catalog resolver. Denial/barrier, cancellation/Close, declaration/case and snapshot-unwind/reuse race cases repeated **100 times**. - Two existing native integration fixtures, normal and `-race`: own-DDL/history/shared reads and subscription/history/role denial. Includes CTAS with an authorizer allowing only its source View, direct system-table user-query denial, and 18 actual ordinary/prepared-template executions across direct/nested/cross-database-intermediate/historical publisher sources, distinguished from subscriber rows/types; also validates ordinary and prepared CTAS planning through the cross-database intermediate View. - `TestViewDescriptionPublicSQL`: existing public SQL/binary PREPARE and empty-result metadata controls. These are compatibility controls, not proof that default binary routing uses S3. - Go 1.27.1 gofmt/vet; golangci-lint **2.14.0** built with Go 1.27.1, normal and integration-tagged scopes. - Modified-block statement coverage on the merged base: **312/331 = 94.26%** (>75%). This CI follow-up adds no separate kernel/test patch beyond the upstream merge. - An earlier validation round hit the unrelated physical-write `elapsed > 0` assertion. Restoring every local Go change to the pre-fix merged baseline through a verified Go overlay reproduced the same zero-duration failure; one subsequent complete owning-package run passed. The original failure and baseline evidence are retained, with no test skips or unrelated product changes. No new BVT golden files: the new entry is internal/opt-in; native fixtures exercise it directly, and the existing public protocol regression checks the unchanged default path. ### QA decision QA is required before activation: tenant/snapshot isolation, CTAS provenance, and reusable-plan metadata are correctness-sensitive. Full cursor, multi-CN, mixed-version, performance, and rollout coverage remain separate gates; this PR does not waive them. Approved by: @XuPeng-SH, @aunjgr, @aptend
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #30654
Fixes #30450
Fixes #30657
Related to #30621 (follow-up CHECK namespace SI fixture correction).
Related audit: #30309, #28638, #30209, #30453, #30454, #30491, #28652 and matrixorigin/CI#450.
What this PR does / why we need it:
Four UT fixtures assert the wrong ownership or transaction boundary:
Publication retry tests require a cleaned child context to retain its parent's deadline error. Explicit child cleanup can validly win that race. Keep the exact policy/parent outcome and immediate termination checks, and retain the live-parent cleanup and successful ownership-transfer controls.
Remaining Group spill/retry fixtures acquire automatic budgets before the existing private-budget helper, so less than 16 GiB of available host disk gives successful spill paths a one-byte budget. Consolidate private budget construction and install it before first use, including partial MergeGroup preparation. Preserve Process memory caps, custom allocation/rejection controllers and explicitly selected generations, with zero memory/disk/FD checks at teardown.
The remote role-refresh test defers DROP ACCOUNT before outer test cleanups close tenant sessions. Complete client cleanup in a child test while shared-fixture admission is still held; close tenant sessions before account removal and retain admin access for removal verification. Failure-path rollback gets a fresh bounded context and checked error.
CHECK namespace repeatable-read autocommit tests assume a catalog drain and SYNCCOMMIT prevent every stale-snapshot abort. They cannot fence a later commit: the existing conservative table-wide lock watermark may validly return 20619 before the expected 3822/3819 check. Recover only the exact catalog namespace abort in a new autocommit transaction, synchronize each attempt and share a 30-second total budget. Keep exact terminal errors, old-row/constraint/name-reuse checks, and the explicit fixed-snapshot rejection test. Reuse the existing two-CN fixture to inject a real intervening commit and assert the actual first abort, a different transaction ID and final CHECK violation. Cancellation and unknown errors stop immediately; timeout diagnostics retain attempts and the last conflict.
All changes are in four test files. Existing text/binary/SQL-prepared, repeatable-read, remote-policy, injected-fault, spill-result, refusal and cleanup assertions remain. No production execution path, retry policy or disk admission policy changes; no production performance impact is introduced.
Validation on authored revision
7952ff8385(Go 1.27.1, Darwin/arm64, matching repository CGo artifacts;-short -tags=matrixone_test, test-result cache disabled):DeadlineExceededwith cleaned childCanceled. Three source mutations removing final cancellation, previous-attempt cancellation or authoritative policy-error return each fail the retained assertions. Focused retry-family race: 100 same-process repetitions passed.go buildfor production owning packages,go vetfor all three owners, formatting/diff checks, and configured incrementalmake static-check-selectedpassed (pinned molint and golangci-lint 2.14.0; zero final issues). The issues directory is test-only and its actual UT binaries compile/link in both modes.Published revision
909b988e5d(main base2196656528) additionally passes complete Group normal/race with the 8 GiB overlay, focused retry/role-refresh plus the newly merged Unicode UNIQUE regression in normal/race (94 nodes each), build/vet and the three-owner configured incremental SCA. All three delivered test-file blobs are identical to7952ff8385; prior whole-issues-package and mutation/stress receipts retain their original revision identity. The unchanged fixture/retry/resource/native owners and these dependency-specific controls support evidence reuse across the main merge.The accompanying historical-issue audit also validates the already-merged shell cancellation fixes on Linux/arm64, Go 1.27.1, Bash 5.2.37 in normal/race mode, including a failing pre-fix lost-TERM control. Those results qualify closing the old tracker; they do not claim the original amd64 full-lane load was reproduced. Startup/post-DDL/telemetry latency, unexplained ancestor cancellation, and external cold provisioning retain their separate trackers where causal repair evidence is missing. New PR CI remains pending.
CHECK namespace continuation validation (commit
81887fa847, same base2196656528, original three delivered blobs unchanged):pkg/embednormal and race passed (359.402s / 457.963s; 491 test/subtest nodes passed and two unchanged pre-existing skips per mode). The skips are the external-MySQL CDC BVT and the already-skipped CN restart test.TestCheckConstraintNamespaceandTestCheckNamespaceSIRecoveryControlpassed in normal and race modes (29 test/subtest nodes per mode), including deterministic real-SQL recovery and both new cancellation-during-SQL controls. These reruns validate the final shared-context and diagnostics corrections after the earlier package binaries compiled; unchanged package scenarios retain their full-package receipts.B=30s, measured rootT=33.85s, henceN=1; the final-source complete root execution qualifies without repeating the entire package.make static-check-selectedpassed with zero configured issues. Formatting and diff checks pass. Go 1.27.1, Darwin/arm64, matching repository CGo artifacts,-short -tags=matrixone_test,-count=1and-race -count=1.gpt-6.1-sol/xhigh. Historical three-file validation above retains its original revision identity; the original three delivered blobs remain unchanged. Updated PR CI is separate and pending.Production lock admission, snapshot isolation and autocommit rollback behavior remain unchanged. The correction acknowledges the existing conservative abort contract; it does not disable conflict detection or retry active fixed-snapshot transactions. No new cluster, production retry, schema/wire format or hot-path overhead is added. The exact advancing transaction in the original CI run is not identified by its logs; the real two-CN reproduction establishes the causal mechanism independently.