Repository navigation
feat(plan): add bounded read-only view schema requests - #29633
Conversation
# Conflicts: # pkg/sql/parsers/dialect/mysql/scanner.go # pkg/txn/client/operator.go # pkg/vm/engine/disttae/txn.go
# Conflicts: # pkg/sql/parsers/dialect/mysql/mysql_sql.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of cab1af2 against 83d82b8: REQUEST_CHANGES for one reproduced P2.
The previous missing creation-time name-mode finding is closed: the common resolver now rejects it before root/nested binding or memo reuse, with explicit mode-zero controls. The added DefaultDatabase restriction, however, rejects valid definitions produced by the current CREATE VIEW owner; see inline finding.
Reviewed all 56 changed files, separating production (+2317/-158), tests/BVT (+3738), documents (+54/-1), and generated parser output. Accepted the recorded S1/S2 v2.1 design decisions; did not reopen the superseded exact-128MiB allocator requirement or S3-S9 activation. Existing parser/binder, private compiler, transaction and execution-resource owners are reused coherently.
Validation: exact-head CI normal/coverage and race groups succeeded; new public numeric BVT passed 17/17. Current CI profile yields 88.54% statement coverage for non-generated production blocks intersecting added lines (1143/1291). Parser generation matches the previously regenerated output apart from the output-path header, with unchanged inputs. Local exact-head producer-to-reader probe fails only without a selected database; the PR's own integration-tagged TestNativeViewSchemaCatalogOwnDDLHistoryAndSharedReads also fails for this same error on outer_a. CI uses matrixone_test and does not select that integration test.
Performance is not zero-impact: shared parser/binder checks and workspace revision atomics affect ordinary paths. Author-reported prior-revision medians were +2.9% planning / +3.6% parsing, while memo reduced repeated-root work; those measurements do not establish current DML-workspace overhead.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
Reviewed exact head cab1af2 against merge-base 83d82b8 after loading the current PR reviews, issue comments, and inline threads. No new blocking or non-blocking finding was proven. The existing unresolved XuPeng-SH blocker remains: pkg/sql/plan/view_schema_legacy.go:40 rejects valid views persisted with DefaultDatabase "" by the current producer at pkg/sql/plan/build_ddl.go:422; per the no-duplication rule it is not repeated as a finding. The remaining plan, parser, function, transaction, disttae, process, native-support, and BVT test files were reviewed without finding an additional defect.
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed exact head cab1af2ec64f47905a6ee0b7c9ac36c30f4ea82a against merge-base 83d82b8ee0cd694e0c6a7146902d74ae4dfb415a, including the complete changed-file set and the prior review threads. CI/check metadata is complete and successful. I found no P0/P1 issue.
[P2] pkg/sql/plan/view_schema_legacy.go:40-42 rejects a valid definition produced by the current CREATE VIEW path. inferViewColumns/genViewTableDef persists ViewData.DefaultDatabase directly from ctx.DefaultDatabase() (pkg/sql/plan/build_ddl.go:420-426). A statement such as CREATE VIEW tpch.v AS SELECT n_name FROM tpch.nation can be created without USE because the source is fully qualified; in that statement context the persisted default database is the known empty string, while the source database is still unambiguous. The opt-in request nevertheless returns LEGACY_CONTEXT_UNAVAILABLE before binding whenever DefaultDatabase == "", so DescribeViewColumns cannot read a view that the current producer legitimately stores. Please distinguish absent/null historical metadata from an explicitly known empty default database and add producer-to-reader coverage for the no-USE, fully qualified case. This remains a non-blocking compatibility defect in the new opt-in API; the existing thread has no author reply.
XuPeng-SH
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES at f578a4a, merge-base a238745. One newly reproduced P2 remains: a published View whose real source is in another publisher database can successfully derive the subscriber's same-named table instead. Both direct and nested descriptions return the wrong column type and dependency account; see inline reproduction.
The two previous findings are closed. Missing creation-time name mode is rejected through the common root/nested resolver guard. Absent/null DefaultDatabase is now distinguished from an explicitly recorded empty string, with actual CREATE VIEW producer-to-reader coverage. The previously failing native own-DDL/history test now passes. Both earlier threads are resolved and their fixes were verified, rather than accepted from thread status alone.
The new subscription change correctly separates the resolved publication database from the saved creation database and shares that decision between root and nested binding. However, retaining a different creation database does not preserve the publisher account for that source lookup: frontend GetSubscriptionMeta only reuses the current subscription for its publication database, so the lookup silently falls back to the subscriber. This violates the existing design's prohibition on publisher/subscriber same-name fallback. The new mocked routing tests only put the source inside the publication database, even when creationDatabase is elsewhere; they therefore miss this real resolver boundary.
The broader architecture remains reasonable under the accepted S1 amendment / S2 v2.1 scope. It reuses authoritative parsing/binding, transaction snapshots and existing execution-resource ownership; no second inference engine, persistent freshness store, worker or catalog publication path is introduced. Public activation is intentionally staged, not dead code. Practical bounds are the approved contract; this review does not reopen the superseded per-allocation 128 MiB proof or require S3-S9 completion.
Reused the recorded complete cab1af2 review for unchanged code, reviewed the no-USE fix and the subsequently arriving four-file subscription fix, and checked both main merges and affected caller boundaries, including row-rewrite propagation. Current map: 57 files; production +2364/-165, tests/BVT +3960/-0, docs +54/-1, generated parser +2118/-1954, assessed separately. Parser inputs/output remain unchanged from the previously verified regeneration. The remaining defect is a missing behavior/identity oracle, not a line-count concern.
| Audit | Closure |
|---|---|
| Q1: ownership/cleanup | Result getters return independent copies; Release is idempotent and serialized with readers. Failure/panic unwinds leases/memo without closing the borrowed parent transaction or execution generation. Subscription state is restored on return/error. |
| Q2: cancellation/waits | Single active binder; cancellation reaches parse/bind/catalog operations. Close cancels before waiting for work and intentionally waits for caller-owned result handles to be released. No additional deadlock or orphan-worker finding established. |
| Q3: bounded growth | Practical input, parse/bind work, depth, columns, attempts, output and memo bounds remain; optional cache bypass preserves authoritative binding and logical work accounting. Existing query admission remains authoritative. |
Independent current-production-head validation on macOS arm64 / Go 1.27.1, using matching local native prerequisites and mo-cgo-test:
- Planner ViewSchema/DescribeViewColumns/ResultScanWithout matrix passed (8.643s); TestBindViewPropagatesOuterRewriteOption passed separately (0.889s).
- The unchanged TestNativeViewSchemaCatalogOwnDDLHistoryAndSharedReads and TestNativeViewSchemaSubscriptionHistoryAndRoleDenial passed (8.49s / 8.73s) alongside appended review-only probes. A no-USE control with qualified publisher sources, nested Views and a subscriber shadow passed (9.72s).
- A real native publisher/subscriber cross-database probe failed: expected publisher INT (type 22), got subscriber VARCHAR (type 61). A second run exercised direct published and nested qualified Views twice each; all four returned VARCHAR and dependency AccountID=1 instead of publisher AccountID=0 (11.249s package time). Real CREATE VIEW/publication/subscription and the native role authorizer were used; no mocked resolver or production edit. The probe was injected through an external Go overlay.
- The first latest-head native attempt hit macOS Unix-socket path length during cluster startup; rerunning with a short TMPDIR reached and completed the assertions above. Current CI run 37907610026 is still pending. Earlier successful run 37892095712 and downloaded BVT belong to 18cbd37, not this new head; I do not count them as latest-head CI success. Full normal/race suites were not rerun locally.
Performance is not zero-impact: shared parser/binder checks and workspace mutation atomics affect ordinary paths. Author-reported prior-revision medians were +2.9% planning time / +3.6% parsing time and +2.7% planner allocation bytes (+32 allocations), while memo reduced repeated-root work. Those historical measurements do not establish current-head TP/DML throughput overhead or later consumer performance acceptance.
XuPeng-SH
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES at 9ce70ee, base/merge-base 0ccc989. One P2 remains, demonstrated through real CREATE VIEW/publication/subscription and the native role authorizer: a subscriber alias can change the meaning of the publisher's saved database name. Direct and nested descriptions return a valid but wrong type and dependency database; details inline.
Prior comments: the missing creation-mode and explicit-empty DefaultDatabase fixes remain valid. The latest publisher-account change fixes the prior cross-database tenant leak: the native non-collision control correctly reads the publisher's INT despite a subscriber VARCHAR shadow. The outstanding older thread has no author reply and remains unresolved in GitHub; that status is separate from the verified account fix. The new failure is a database-namespace collision, not the old account-selection failure.
Design/ownership: the accepted S1 amendment / S2 v2.1 remains a reasonable bounded opt-in design, reusing the authoritative parser/binder, transaction visibility and execution ownership. Public activation is intentionally deferred. The publisher context borrowing, snapshot copies, temporary-table exclusion and restoration fit that ownership. However, unconditionally interpreting a stored source name as the subscriber alias conflates two namespaces. Resolve, GetDatabaseId, UDF lookup and root/nested binding need one consistent boundary rule; another fallback would not solve this.
Reused the prior complete review for semantically unchanged code and examined the new five-file fix plus affected base-merge interactions. Current full delta: implementation +2446/-174 (36 files), tests/BVT +4286/-0 (19), docs +54/-1 (2), generated parser +2118/-1954 (1). The added mocked routing cases cover publisher accounts and counterpart lookup methods, but lack the real alias-collision producer/reader oracle. No new independent cleanup, cancellation, growth or ordinary-TP blocker was established. Existing caller-owned result release, cancel-before-wait ordering and bounded memo/work contracts remain applicable.
Current-head validation on macOS arm64, Go 1.27.1, matching native prerequisites via mo-cgo-test:
- TestViewSchemaSubscription* passed (frontend package 3.707s).
- Reviewer-only integration overlay TestReviewViewSchemaPublisherAliasCollision completed and failed its behavior assertions (12.179s package time): the non-collision control returned INT with sys/review_other provenance; direct and nested collision cases returned VARCHAR with sys/review_vpub provenance on both reads. CREATE VIEW's stored schema independently confirmed all three views were INT. Parent transaction/catalog and workspace stamps stayed unchanged, and fixture teardown completed.
- Exact-head CI Required, Linux UT/coverage and PROXY BVT are successful in run 38023578122. Those jobs do not cover the newly demonstrated native collision. No full local race suite or TP throughput benchmark was rerun.
The latest fix adds context/snapshot work in the opt-in derivation path; it does not establish zero overhead for the entire feature. Previously recorded shared parser/binder/workspace overhead remains a performance consideration, not a newly measured TP result.
XuPeng-SH
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES at 47073c0, base/merge-base 8adb9d8. One reproduced P2 remains: an inherited active subscription contaminates an ordinary subscriber-local root's dependency identity and source binding. The exact reproduction and owner-level fix request are inline.
Previous comments are substantively closed. The missing creation mode and absent-vs-explicit-empty DefaultDatabase guards remain valid. The earlier cross-database publisher-account case and publisher-name/subscriber-alias collision now pass through real catalog resolution. The revised separation of entry names and stored publisher names is the right direction. However, the new root resolver only changes the lookup method: it does not scope the inherited subscription out of root dependency capture or ordinary-root inference. The author test explicitly covers an inherited subscription but only describes published roots, so it misses the adjacent local-root case.
Native counterexample, same real CREATE VIEW/publication/subscription fixture and production role authorizer:
| Parent active subscription | Describe(review_other, local_view), first and repeated read | Expected |
|---|---|---|
| nil | VARCHAR, root/source AccountID=1 | subscriber VARCHAR, AccountID=1 |
| sys/review_vpub as review_alias | INT, root/source AccountID=0 | subscriber VARCHAR, AccountID=1 |
Subscriber account 1 owns review_other.source(id VARCHAR(30)) and local_view over that table. Publisher sys owns a same-named review_other.source(id INT). The root lookup still returns the subscriber local_view RelationID, but the result even labels that subscriber relation as AccountID=0. Parent catalog/workspace stamps remain unchanged and teardown completes. This is a wrong-success result of the new opt-in API, not a claim that public DESC/SELECT have already activated it.
Design and scope closure: retained the approved S1 amendment/S2 v2.1 practical-bounds decision and reviewed the namespace clarification against its existing identity invariant. Existing parser/binder, transaction snapshot and execution-resource owners remain authoritative; public consumer activation is intentionally staged. No need for another inference engine or state machine. Reused the previous complete review for unchanged contracts and compared the complete old and new PR deltas: only six files have different semantic added/deleted hunks, all reviewed, plus traced affected base-merge callers. Parser inputs/generated output are unchanged from the previously verified regeneration. Q1-Q3 ownership, cancel-before-wait, caller-owned result release, context restoration, and bounded memo/work remain applicable; no additional independent cleanup/liveness/growth blocker was established.
Increment assessed separately: non-generated implementation +2459/-174 in 36 files including grammar; tests/results +4339/-0 in 19; documents +54/-1 in 2; generated parser +2118/-1954 in 1. The follow-up alone is implementation +26/-13, tests +60/-7, docs +1/-1. Its native regression reuses the existing cluster and adds meaningful type/provenance controls; the missing dimension is ordinary roots under inherited subscription state.
Evidence on this head:
- Matching native prerequisites built; repository mo-cgo-test on macOS arm64 / Go 1.27.1, integration tag, external test overlay only.
- Updated TestNativeViewSchemaSubscriptionHistoryAndRoleDenial: PASS, 8.96s; includes five alias/default-database/cross-account cases, repeated reads, historical reads, denial and parent-state preservation.
- Original reviewer TestReviewViewSchemaPublisherAliasCollision: PASS, 8.88s; direct/nested collision and non-collision shadow controls, first/repeated reads. Combined frontend package: PASS, 19.864s.
- New TestReviewViewSchemaInheritedSubscriptionLocalRoot: FAIL, package 10.010s; nil-active control passes, active-subscription case reproduces the wrong type and both wrong dependency accounts on both reads. No production edits.
- Exact-head CI run 38038712353: SUCCESS. Downloaded checkpoint artifact 11666920517 confirms affected frontend/parser/txn/process/disttae/logtailreplay/readutil race-group selection and successful termination, function race group success, planner eight shards success. The integration-tagged native tests are not selected by its matrixone_test tag and were therefore checked locally.
- Compose execution artifact 11665249960 confirms view_definition_numeric_bounds.sql selected and 17/17 passed, zero failures/ignored/abnormal.
Performance: this follow-up adds a bounded root interface dispatch and removes source-name rewrites in the opt-in path. The feature as a whole still adds shared parser/binder checks and workspace revision atomics. Previously reported +2.9% planning time / +3.6% parsing time / +2.7% planner allocation bytes are historical measurements, not current-head TP/DML throughput proof. No new measured TP regression or zero-overhead claim is made.
# Conflicts: # pkg/sql/parsers/dialect/mysql/mysql_sql.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 501a0c535cbdc91a14233f8bce0c226d9e374394 against main@64b715a8234e272794185e2acc98ad58a8346c65.
APPROVE. The four prior reproduced P2 cases are fixed and their threads are resolved: unknown legacy name mode is rejected; known empty creation database is retained; publisher cross-database sources resolve under publisher identity; and a real publisher database whose name collides with the subscriber alias is not redirected. The last root-scope issue is also fixed: an inherited subscription is removed for ordinary subscriber-local roots and dependency capture, then restored for the caller. The new native integration matrix exercises direct/nested published views, alias collisions, historical dependencies, repeated/memoized reads, ordinary local roots with and without inherited subscription, and preservation of caller identity/snapshot.
The design remains bounded and opt-in, reusing CREATE VIEW parsing/binding, existing transaction/catalog visibility, and execution-resource ownership; it does not add a second inference engine or persistent freshness state. The parser regeneration and the added tests/doc changes are scoped to that contract. I found no remaining confirmed design, correctness, cleanup, or ordinary-TP blocker in the changed paths. Exact-head CI Required, Ubuntu UT, SCA, coverage, and PROXY/pessimistic multi-CN BVT all pass.
Merge Queue Status
This pull request spent 11 seconds in the queue, including 1 second running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #29437
What this PR does / why we need it:
Stored View columns can lag behind the source schema visible to a statement. Add an opt-in, statement-owned request that derives current metadata through the existing CREATE VIEW parser and binder. Results own their columns, provenance and CTAS default policy, required protocol version, and transitive catalog dependencies. An isolated compiler reads the caller's transaction, own DDL, historical snapshot and subscription domain; each root is authorized before lookup, including memo hits. The read does not publish a regenerated definition.
The request freezes its binding environment and checks transaction/workspace, role, snapshot, protocol and execution-generation changes. Statement-local memo has bounded retention; nested reuse is restricted to transparent single-source projections, while other shapes retain authoritative binding. Input, parser/binder work, depth, columns, result and memo limits preserve cancellation and existing query admission. Error, panic and close paths return owned resources without closing the parent's transaction or execution generation.
The included S1 amendment and S2 v2.1 design record the approved scope: reuse the existing parser/binder, with practical hard bounds, instead of a per-allocation 128 MiB proof or copied grammar, binder and third-party dependencies. Existing public SQL entry points do not activate the new request, and no background worker or wire/catalog format is added. Shared-path fixes retained here cover numeric grammar overflow, iterative scanning, JSON_ROW error cleanup, missing result_scan arguments, function detection, and snapshot checkpoint/bitmap ownership.
Validation on macOS arm64 with Go 1.26.4, isolated caches and the repository CGo wrapper:
7754db4ca4311d56939f9837bdf7fe3f51046422: mo-tester 356/356 twice on the same owned instance, with zero skipped or abnormal cases. New expected results were generated with mo-tester.make err-check, and CI-version golangci-lint passed; golangci-lint reported 0 issues. CI-version molint exited 0. Its only added diagnostic relative to main is the reviewed parserrecover: it accepts only this invocation's private cancellation/limit abort, rethrows unrelated panics, and preserves cleanup. This is not a claim of zero molint diagnostics.625404fd7d; planner allocation bytes were +2.7% (+32 allocations), while parser allocation count was unchanged. These are representative S2 measurements, not completion of the later S6/S8 consumer benchmarks.Merged
mo/mainthrough625404fd7d665f8d82356cdd8440f0876abfb24aand reran the affected validation matrix. Final self-review and independent source reviews have no remaining blockers. Local TODOs, recovery snapshots and temporary evidence are excluded from this PR.QA Decision
QA required: yes — shared parser/binder and snapshot cleanup paths are affected even though the new request remains opt-in. Verify ordinary SQL planning, cancellation and cleanup, view metadata, role/snapshot isolation, and bounded request behavior on the deployed revision; the local measurements above do not complete later consumer performance acceptance.