Repository navigation
Description
Parent Issue
Parent issue: #26227
Detail of Subtask
Validate and close correctness gaps in on-demand View metadata binding across CN/frontend execution and plan reuse, building on #29139.
Fixed architectural direction
On-demand binding is the required direction, not an alternative to be reconsidered in this subtask. The persisted semantic View definition is authoritative. Current output-column metadata is derived through the shared View descriptor against the caller's transaction-visible catalog snapshot and binding context:
Columns(view, snapshot, context) = Describe(Bind(ViewDefinition, snapshot, context))
Persisted derived View columns are compatibility storage, not the source of truth for current public metadata. Do not reintroduce durable derived-metadata recovery, authority leases, completion generations, or a cross-request cache of derived descriptions as a substitute for this contract.
Deliverables
- Audit the actual paths for
DESC/SHOW [FULL] COLUMNS,information_schema.columns, and View result metadata, including direct execution, SQL PREPARE, binary prepared statements, COM_QUERY plan reuse, and supported SELECT cursors. Map existing guarantees and tests first; fix demonstrated gaps at their owning boundary rather than building a parallel framework. - Preserve planner-produced catalog dependencies and existing plan validation/rebuild mechanisms. Track every object whose identity, definition, or schema determines a reused plan, including a SHOW target that is initially an ordinary table and may later become a View. Preserve transitive source, snapshot, and subscription identities. Do not infer dependencies or sensitivity from SQL text.
- Keep description generation, metadata rows, result-column definitions, and authorization within the same execution generation and caller-visible context. Reuse must not retain invalid descriptions or obsolete visible-object sets; do not blanket-disable ordinary SQL caching.
- Keep mutable binding state request-local, with bounded work and cleanup on success, error, cancellation, and reuse. Borrowed parent transactions must not be committed, rolled back, or closed by metadata-description cleanup. Use existing supported retry boundaries; do not introduce a metadata-specific recovery/retry protocol or silently switch snapshots.
- Provide a compact acceptance/evidence map showing what is already satisfied by fix: derive current View metadata on demand #29139 and subsequent changes, what this subtask fixes, and any concrete remaining gap. Reuse valid existing evidence instead of duplicating whole test suites.
Acceptance criteria
- Public View metadata matches the shared descriptor for the same visible snapshot and binding context, without falling back to stale persisted column descriptions. Existing single-object versus batch invalid-View behavior is preserved; cancellation and internal failures must not be hidden as valid metadata.
- Relevant target/source DDL invalidates or rebuilds reused metadata plans correctly. Deterministic regressions cover source-column changes, View-definition changes, same-name object replacement (including table → View → table), missing dependencies, and repair, using the applicable direct/prepared/cache paths.
- SQL PREPARE and binary prepared executions expose descriptions/results consistent with their execution generation. New cursor executions use the applicable current binding; FETCH of an already-materialized cursor remains consistent with the snapshot and metadata established by its EXECUTE. Unrelated later DDL does not retroactively invalidate that legitimate result.
- Account, active-role visibility, subscription/publisher identity, and historical-snapshot semantics are preserved. Historical transactions may legitimately observe historical metadata; "current" does not mean bypassing the caller's snapshot to read globally latest state. Relevant Data Branch/restore replacements use these same catalog identity/snapshot rules, not a derived-metadata recovery gate.
- Metadata failures remain scoped to the affected request under the established public error contract; unrelated ordinary base-table SQL remains usable. No whole-CN shutdown, background readiness dependency, unbounded work/retries, sleeps for correctness, or leaked request resources are introduced.
- Focused UT and real SQL/protocol regressions prove the affected contracts, including negative paths and nearest controls. Use existing fixtures, generate and verify BVT results with mo-tester, and require race or multi-CN evidence only where an identified concurrency/topology risk needs it. Record existing evidence and remaining gaps explicitly before closing this issue.
Describe implementation you've considered
Extend the already-merged on-demand descriptor and frontend plan-reuse paths rather than introducing a new authority subsystem. Existing dependency metadata should drive invalidation and rebind where descriptions are captured during planning; execution-time metadata sources should resolve under the caller's execution context without caching derived rows across requests.
This scope does not require the former default-disabled authority feature gate, separate planning/authority leases, response-packet/flush or COMMIT epoch fencing, durable recovery workers/generations, recovery-specific lock ordering, or a new whole-transaction recovery loop. These are no longer deliverables or prerequisites for this subtask.
Do not remove or repurpose already-merged shared barrier/protocol mechanisms as incidental cleanup. Preserve existing mixed-version and catalog-upgrade compatibility gates. Physical removal of legacy persisted View column records is a separate migration decision, not part of this task.
Additional information
- Architectural baseline: approved on-demand View metadata design, implemented by merged PR fix: derive current View metadata on demand #29139. This replaces the former dependency on the durable catalog recovery subtask.
- Draft PR fix(planner): invalidate SHOW metadata after target replacement #29451 fixes a confirmed gap: SHOW prepared against an ordinary table omitted its target dependency and could read stale persisted columns after replacement by a View. It adds planner dependency propagation checks and two-session public regressions. This is evidence for that specific gap, not automatic completion of every acceptance item above.
- Scope updated to make on-demand binding the fixed direction and remove obsolete authority/recovery requirements. Keep this issue open until the revised acceptance map is closed with evidence.
Activity
feat(hakeeper): implement catalog metadata capability barrier (#29004) (
[-][Subtask]: Implement CN and frontend metadata authority fencing[/-][+][Subtask]: Validate and harden on-demand View metadata execution and plan reuse[/+]fix(planner): invalidate SHOW metadata after target replacement (#29451)