Repository navigation
fix: derive current View metadata on demand - #29139
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 28e2a61edc24561601526098e9f89585525d0f24 against 3f0a68bd8034d37e098765920f328985c308c9ff. Request changes for two current CI failures introduced by the latest commit, detailed inline.
The previously reported subscription snapshot regression is fixed. I reran the same real-SQL subscriber/publisher probe on this head: current newly added View, historical retained View, historical post-snapshot added View (0 rows), and historical post-snapshot dropped View (1 row) all passed. The earlier design, V58 rolling-upgrade, charset/collation, and PR-description comments also remain resolved.
The new CI run has owning UT and compose/proxy BVT passing, but SCA fails at the new hiddenRows.Close() and pessimistic BVT fails three SHOW CREATE TABLE information_schema.columns checks because the new CTE changed the generated DDL without corresponding result updates. Coverage/CI Required fail downstream. Please fix both checks and rerun them.
Performance evidence from the previous head remains relevant to this mostly metadata-scoping update: on one warm single-CN fixture, V58/current median was 6.1→11.3 ms for one View, 6.3→21.0 ms for a shared-dependency View, and 7.0→33.8 ms for a 55-object scan. This shows overhead; it is not a production-scale benchmark or a separate blocker. I found no additional confirmed resource/cancellation defect in the changed paths.
# Conflicts: # pkg/defines/const.go # pkg/sql/compile/sql_executor_context.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head e4dd1bdef6b3f604b02eba5ee7ef9707f67974cb against b1b68925d7f6fb32153e788b5285f424222e85ca. Request changes: two new, independently reproduced P2 regressions in UDF-backed View metadata, detailed inline.
All four previous inline comments are now addressed: V58 subscription compatibility, charset/collation parity, deferred row cleanup, and all three SHOW CREATE result updates. The prior design-gate discussion is also closed. The definition-authoritative/on-demand design is proportionate and avoids the superseded recovery framework; the remaining problems are incomplete binding-context contracts, not a reason to reintroduce that framework.
Validation at this head:
- Focused tests passed in seven affected packages. Real SQL
TestViewDescriptionPublicSQLandTestViewDescriptionSubscriptionpassed, including prepared reads, source changes/repair, historical snapshots, V58 migration, privileges and charset parity. - Reviewer-only two-CN subscription probe passed normally and with
-race: non-admin metadata reader, TP/AP scheduling, 1/4 concurrent UNION branches, repeated on the same instance; teardown completed. - Live SHOW CREATE output matched all three changed
.resultrows exactly, including DDL length 20832. Focusedsqlclosecheckpassed with 0 issues. - A separate UDF probe used the same current binary/catalog with V58/current COLUMNS definitions. V58 public-other-database and internal-executor controls passed; current public-other-database and internal-executor cases failed. Current public access while using the View's definition database passed.
No additional confirmed cleanup/cancellation defect was found. Earlier performance evidence remains a non-blocking caution: warm metadata reads grew from roughly 6–7 ms to 11–34 ms depending on dependency/scan shape; this is not production-scale capacity evidence. Prefer workload measurements and focused optimization, not another speculative cache/recovery layer. The PR body should also say protocol 98, matching code.
I did not wait for pending CI or change production code. Please fix both UDF context boundaries and add public/internal regression coverage; treating these valid Views as skippable invalid Views would not fix the contract.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 123aef39abd291f21068384b287e4ae09bb771e1, with no subagents. Request changes for one independently reproduced P2 UDF-context defect, detailed inline.
Historical comments:
- The definition-authoritative/on-demand design and invalid-View error-contract decision remain resolved. The design avoids adding another durable recovery/cache system.
- The four older inline findings remain addressed: V58 subscription-View compatibility, charset/collation parity, deferred hiddenRows cleanup, and all three SHOW CREATE expected-result updates.
- The latest two I_S UDF reproducers are fixed: the existing public same/other/no-default-database and no-frontend internal-executor test passed locally at this head. However, the intended database-context contract is not closed across DESC/SHOW COLUMNS: its dependency-recording wrapper loses the new resolver interface.
Validation and closure:
- Reused exact-head successful required CI; the UT log explicitly records PublicSQL, Privileges, TwoCN, Subscription, and UdfDatabaseContext passing. Previous two-CN TP/AP concurrent subscription-metadata race evidence remains relevant to unchanged isolation/ownership paths; it was not rerun or relabeled as a fresh race run.
- A separate reviewer-only real-SQL probe passed the same-database DESC and cross-database I_S controls, but failed both cross-database DESC/SHOW FULL COLUMNS. Adding a different same-named UDF in the caller database changed the reported column from BIGINT to VARCHAR(7), confirming wrong resolution rather than a missing-function-only error.
- Traced private child contexts/processes, partial-batch cleanup, borrowed transactions, cancellation/error propagation, publisher snapshots, prepared dependencies, authorization-before-binding, and scan/expansion/column bounds. No additional confirmed lifecycle defect.
Performance remains a non-blocking caution, not a claimed optimization: earlier warm single-CN V58/current metadata measurements were approximately 6–7 ms versus 11–34 ms depending on dependency/scan shape. These are historical focused measurements, not fresh production-scale capacity proof. Prefer filtered/large-catalog workload measurements and targeted optimization, not speculative caching.
Integration note: this PR and #29387 both currently allocate MORPC v98 for different capabilities. Reconcile the allocation, gates, and tests in whichever lands second; these reviews are scoped to each current head independently. Production code was not modified.
# Conflicts: # pkg/defines/const.go
# Conflicts: # pkg/defines/const.go
aptend
left a comment
There was a problem hiding this comment.
Deep re-review at exact head 5f212fd, following all prior reviews and seven resolved inline threads. I compared the incremental UDF-resolution fix after 123aef3 with the full 56-file on-demand View metadata contract. The DESC/SHOW dependency wrapper now forwards the definition-database resolver, the frontend and internal-executor paths bind UDFs under the View's persisted database/snapshot, and the real SQL regression covers cross-database/no-default callers, conflicting same-name UDFs and prepared SHOW. The earlier V58 subscription, charset, hiddenRows and SHOW CREATE regressions remain closed in the full diff. I found no confirmed new blocking correctness, lifecycle or authorization issue.
Exact-head TestViewDescriptionUdfDatabaseContext and TestViewDescriptionSubscription passed in an isolated worktree with native dependencies; focused plan/compile/sysview tests passed. This approval does not waive CI or merge readiness: the current required Ubuntu UT run failed in TestIssue23861FulltextSnapshotRestore (outside this patch), and the PR is currently conflicting with the advancing main branch. Rebase/resolve and rerun required checks before merge; any changed head needs a fresh review.
# Conflicts: # pkg/sql/compile/sql_executor.go # pkg/sql/compile/sql_executor_context_test.go # pkg/sql/plan/pushdown.go
# Conflicts: # pkg/bootstrap/service_statistics_upgrade_test.go # pkg/bootstrap/upgrade.go # pkg/bootstrap/versions/v4_0_9/upgrade.go # pkg/bootstrap/versions/v4_0_9/upgrade_test.go # pkg/cnservice/tenant_upgrade_test.go
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review at exact head a3362bc7e0586cc88c1ca8893808afb3a3f523d9: APPROVE. The previous design, rollout, charset/collation, hiddenRows cleanup, SHOW CREATE result, UDF database-context and DESC/SHOW dependency-wrapper findings are all resolved; GitHub shows the corresponding review threads resolved, and the current real-SQL test covers public and internal paths, no/default/other database callers, conflicting same-name UDFs, prepared SHOW and subscription parity. The 4.0.10 tenant migration follows main’s 4.0.9 cluster upgrade and protocol 100 is allocated after row-lock 99; the earlier FORMAT collision in #29387 is no longer live because that PR merged to main on 2026-09-27. The definition-authoritative, on-demand design remains proportionate and avoids a second durable cache/recovery mechanism. Exact-head required CI, UT, SCA, coverage, Connector/J, PROXY and pessimistic BVT pass. Performance caveat: prior focused warm single-CN measurements showed roughly 6–7 ms → 11–34 ms depending on View dependency/scan shape; this is evidence of overhead, not a production-scale capacity benchmark or proof of performance improvement. No additional blocking issue found.
Merge Queue Status
This pull request spent 4 minutes 49 seconds in the queue, with no time running CI. ReasonPull request #29139 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29005. Part of #26227.
What this PR does / why we need it:
This adopts the on-demand binding design suggested in review. The semantic View definition remains authoritative;
DESCandinformation_schema.columnsbind it against the caller's current catalog snapshot instead of relying on a persisted derived column snapshot.Read path
DESC/SHOW [FULL] COLUMNS, includingLIKEandWHEREfiltering.mo_view_columnsmetadata operator forinformation_schema.columns. Visible View candidates are selected by the existing role-aware metadata boundary before binding.Compatibility and bounds
information_schema.columnsdefinition (after main's 4.0.9 snapshot-quota cluster upgrade); a persisted V58 definition continues to work on newer CNs until migration.*, SQL mode, default database, security and snapshot semantics from persistedViewData.information_schema.columnsdefinition; direct SQL use is rejected.Validation
go vetpassed; incremental golangci-lint passed with 0 issues;make err-checkpassed.view/view_metadata_on_demand.sqlwas generated from real SQL, reviewed, and passed original mo-tester comparison twice on the same clean owned service (18/18, twice).Notes
Public metadata admission no longer depends on a background recovery protocol. For an invalid visible View, batch
information_schema.columnsscans warn and skip that View while retaining valid rows; directDESC/SHOW COLUMNSreports the invalid dependency. Cancellation, protocol and internal failures remain fatal. A filtered-out or unauthorized View is not bound. Fixing the dependency makes the next read succeed without recovery state.