Repository navigation
feat(plan): add opt-in derived view query planning - #30551
Conversation
|
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: ab76739f6f15b52813b5f32ff45b37bc276e33a0
Assessment: request_changes
Reviewed the complete 14-file delta and surrounding owners. The opt-in design reasonably reuses the binder, request lifecycle and dependency validators. Current-head validation closes the historical snapshot concern, but confirms that prepared DUAL queries still receive incorrect physical-table authorization.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
- P2
pkg/sql/plan/query_builder.go:7247: PlanSELECT 1 AS one FROM dualthrough direct prepared planning, text PREPARE or typed PREPARE with a root authorizer that rejects physical-table access.
Impact: A valid constant query fails authorization despite accessing no physical table. Classify unqualified DUAL before this optional metadata probe and skip its authorization/Resolve calls; preserve authorization for qualifieddb.dualand add regression controls for all entry modes.
Evidence: buildTable classifies unqualified DUAL as a placeholder at line 12941, but this earlier probe invokes authorizeRoot and preserves its denial. Current-head planner and native frontend probes each reproduced failures in all three prepared modes. Ordinary DUAL and every no-FROM control passed with zero authorization calls; qualified-DUAL planner controls remained protected. See planner-focused.log/checks/1792474449941846879-5.json and native-focused.log/checks/1792474668506039562-3.json in the diagnostic directory.
Validation:
-
Evidence directory: /home/xupeng/.local/state/mo-bot/jobs/25361509bf0b50d1c13fb8af/attempt-1. review-evidence-audit.json reconciles commands, source fingerprints, native provenance, overlay hashes, logs and exit receipts. Source remained unchanged.
-
Isolation preflight and repository-owned native build passed. Tests used the supplied test-exec and assigned task caches.
-
Complete pkg/sql/plan and pkg/frontend suites passed with existing skips: owning-normal.log; receipt 1792474719170885978-3.json, exit 0.
-
Focused race tests passed, including planning cancellation, Close/BUSY, provider ownership and dependency invalidation: focused-race.log; receipt 1792474903656452737-3.json, exit 0.
-
Planner snapshot authorization tests and additional historical dependency probes passed across ordinary/direct/text/typed modes. The only failures in planner-focused.log were the three DUAL reproductions.
-
Both existing native fixtures passed, including own-DDL/history, publisher/subscriber execution, CTAS and role denial. Child ownership and cache invalidation tests also passed. The native command exited 1 solely because of the three DUAL reproductions.
-
Design, ownership, compatibility, test quality and performance analysis are retained in review-scope-notes.json.
Limitations:
-
local_validation contained no retained worker gates. Linked issue bodies were absent; requirements were assessed from the frozen PR evidence and versioned design contracts.
-
Native fixtures ran in normal mode; race validation covered focused planner/provider tests. Default activation, cursor, multi-CN and mixed-version rollout remain outside this opt-in scope.
-
No comparative performance benchmark was run. Opt-in rebinding and owned dependency copies add work; no speedup or comprehensive absence of regressions is claimed.
|
mo-bot review · Commit: "interrupted" |
|
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: e25177d820ea73f79951ef6f28f540d2bb689862
Assessment: request_changes
Reviewed the complete 14-file delta and surrounding owners. Reusing the existing binder, request lifecycle and dependency validators is sound. Current-head tests close the earlier DUAL and snapshot-probe concerns, but one reproducible panic/reuse defect remains.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
- P2
pkg/sql/plan/view_schema_planning.go:73: Reuse a ViewSchemaRequest after recovering a catalog panic while planning a historical View whose body contains a CTE.
Impact: The compiler retains the historical snapshot. A subsequent query without a snapshot hint is authorized and planned in that historical domain, violating the documented recovery contract. Defer restoration of the compiler snapshot around BuildPlan, or make the temporary CTE snapshot change panic-safe.
Evidence: bindNoRecursiveCte changes the compiler snapshot and restores it only on normal return; state.close restores context and leases, not snapshot. TestReviewViewSchemaPanicRestoresSnapshot reproduces historical authorization and CatalogDependencies on the next current query. Direct-source and existing Describe controls pass. See snapshot-reuse-controls.log and checks/1792482964607735872-4.json (exit 1).
Validation:
-
Artifacts: /home/xupeng/.local/state/mo-bot/jobs/118b37f03111da3a6cc2041e/attempt-1. validation-audit.json reconciles commands, fingerprints, logs, exits and probe hashes; review-scope-notes.json records design, ownership, performance and test analysis.
-
Isolation preflight, repository-owned native build and provenance verification passed. Tests used Go 1.27.1, Linux amd64, assigned caches and test-exec.
-
Complete pkg/sql/plan and pkg/frontend suites passed in normal and race modes, with existing skips. Receipts: 1792482840482793803-3.json and 1792483405223628918-3.json.
-
Cancellation/Close and denial-before-catalog tests each passed 100 race repetitions. Both native View-schema fixtures and TestViewDescriptionPublicSQL passed, covering publisher execution, history, CTAS, authorization and default-route compatibility.
-
Changed-file gofmt and whitespace checks passed. Final audit verified 11,617 tracked files and 190 native inputs; source remained unchanged. Audit receipt: 1792483450914463844-4.json, exit 0.
Limitations:
-
The finding concerns the reusable opt-in API and was demonstrated with an injected catalog panic; default SQL routing remains unchanged.
-
local_validation was empty and linked issue bodies were absent. Available contracts came from frozen PR evidence and versioned design documents.
-
No comparative performance benchmark or independent changed-code coverage percentage is claimed. Cursor, multi-CN, mixed-version and default-activation qualification remain separate rollout gates.
|
mo-bot review · Commit: "interrupted" |
|
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: 6b518c7395ac842ec603c5ea1411b53b2c53229d
Assessment: approve
Reviewed the complete 16-file delta and affected callers. The bounded opt-in design appropriately reuses the existing binder, request lifecycle and dependency validators. Validation closes the earlier DUAL authorization, historical snapshot and panic/reuse findings. No actionable blocker remains.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Full planner and frontend suites passed normally and under race, with existing unrelated skips. The initial planner race run exceeded 300 seconds; its complete rerun passed in 483.6 seconds.
-
All 35 focused race tests passed. Denial-before-blocking-catalog and cancellation/Close tests each passed 100 race repetitions.
-
Both native integration fixtures passed, covering executable plans, publisher/subscriber identity, historical snapshots, CTAS and role denial. Separately selected TestViewDescriptionPublicSQL passed. Integration-tagged go vet passed.
-
Base/head benchmarks measured modest bookkeeping costs: one-CTE planning added approximately 1.4 KB and 7% median time; 32 CTEs added 10.6 KB and 3%. The 128-CTE case was approximately 17% faster. The no-CTE control added 32 bytes and one allocation.
-
Final audit verified 11,655 tracked files unchanged, 198 matching native build inputs and 46 native artifacts. Commands, overlays, logs and exit receipts are reconciled in /home/xupeng/.local/state/mo-bot/jobs/55ed4ec441040226da452b90/attempt-1/validation-audit.json; audit receipt checks/1792515978365042725-4.json exited zero.
Limitations:
-
Approval covers the explicit opt-in API. Default activation, cursor, multi-CN, mixed-version and comprehensive performance qualification remain separate rollout gates.
-
Native integration fixtures ran in normal mode; race evidence covers owning packages and focused lifecycle stress. Benchmarks measure narrow parser/planner workloads.
-
local_validation was empty and linked issue bodies were absent. Requirements were assessed from frozen PR evidence and versioned design contracts; author-reported raw validation was not treated as independently verified.
Merge Queue Status
This pull request spent 2 hours 49 minutes 16 seconds in the queue, including 54 minutes 30 seconds running CI. Required conditions to merge
|
aptend
left a comment
There was a problem hiding this comment.
Independent deep re-review of exact head f59f8fe34652e4d795377336a6328b3a68c9126b, declared base/merge-base 63a964a82fbaae4759cfabb45655e0185bc0979c, against my prior reviewed head 9c5be2d0dc064b4b07345fdd80cbe3f781dcb62c.
Read every current changed hunk (16 files), all six historical reviews, all discussion/inline comments and both resolved threads. Re-reviewed the current S3 design amendment as a distinct phase and retained acceptance for the explicit bounded opt-in API only. No remaining blocking finding.
Both issues from my previous REQUEST_CHANGES are closed by implementation and independently executed current-head evidence: optional probes use the binding context's effective snapshot for authorization AND resolution/dependency capture, deferring unresolved time hints; unqualified DUAL shares the binder's placeholder classifier before physical authorization, while qualified DUAL remains protected. The ordinary/direct/text/typed matrix checks historical-only dependencies and nearest negative controls. The native fixtures actually execute all four DUAL modes and validate historical schema selection.
Also traced declaration-order/ancestor CTE masks, case-sensitive names, numeric propagation/scalar consumers, CTAS source-versus-target snapshot rules, trusted catalog SQL isolation, publisher execution/dependency identities, real executable subtrees versus description memo, and panic/error snapshot restoration before same-request reuse. Q1/Q2/Q3 remain closed: request owns child/leases, caller retains parent transaction and independent returned plan; Close cancels before waiting on its gate; per-request work/memo bounds remain, with no new global cache/background owner.
Fresh independent validation in detached exact-head worktree (Linux amd64, Go1.27.1, CGO enabled, own provenance-stamped make -j4 cgo, repository test wrapper):
- Full
pkg/sql/planandpkg/frontendnormal: PASS, 49.318s / 14.362s. - Full owning packages once under race: PASS, 199.914s / 25.725s.
- Denial-before-blocking-catalog and cancel/Close: each exact root separately race PASS x100; measured T=.01s / below resolution, B=30s, capped N=100. No package-wide repeated stress.
- Both integration-tagged native fixtures: PASS, 6.82s / 6.48s, covering actual publisher-specific values/types, subscription/history/RBAC, CTAS and request/parent ownership.
- Separate actual
pkg/tests/upgrade/TestViewDescriptionPublicSQL: PASS, 5.65s, default-route compatibility control only. - Integration-tagged owning-package
-vet=allandgit diff --check: PASS.
No source patches or temporary adversarial tests were needed this round. Full GitHub CI/coverage jobs were still pending at the final check, not counted as passing local evidence; no independently measured changed-code coverage or comparative performance claim. Approval does not activate default SQL/PREPARE/cursor routing or waive the separate multi-CN, mixed-version, performance and rollout gates.
What type of PR is this?
Which issue(s) this PR fixes:
Refs #29438 (S3 of #29433; builds on S1/S2).
What this PR does / why we need it:
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.
db.dualremains a protected physical root.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.DeepCopyObjectRefand attach the effective publisher account to executable physical-table references and dependency copies; preserve request/plan ownership across cancellation and Close.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.Implementation and consumer audit: S3 design.
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@76e152a1dd02b7875829027117a6f6344d1f8d33, using Go 1.27.1, darwin/arm64, and the repository CGo wrapper:pkg/sql/planandpkg/frontendowning packages in normal mode; affected View-schema and snapshot/internal-SQL tests with-race.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 test: fix transaction, context and resource ownership in UT fixtures #30670 rather than maintaining a duplicate fix. The exact failing subtest and complete CHECK namespace/recovery group pass locally with CI'smatrixone_test,-short, and-raceflags. 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.-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.elapsed > 0assertion. 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.