Repository navigation
fix(planner): invalidate SHOW metadata after target replacement - #29451
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of feb577b121ad07c57f0fb7b350620294a6e4ec4e, merge-base d99187d7b3bfda8744088b3ae8cf16739b690aa0. APPROVE: no blocking findings. Reviewed directly without subagents.
Design. The fix belongs at the dependency producer: an ordinary SHOW target determines plan-time formatting and the choice of metadata row source, so it must be tracked before it can be replaced by a View. Moving target capture outside the View-only condition closes that omission using the existing validation/rebuild machinery. It aligns with the approved on-demand metadata design and #29006's revised scope. This ordinary bug fix needs no additional state machine or feature design document.
Closure checked. I read every changed hunk and followed target resolution -> dependency capture/deduplication -> plan deep copy/wire/PREPARE -> prepared schema validation and COM_QUERY checkModify -> rebuild/error handling. Target identity/version and database identity are captured, existing View source dependencies remain, and subscription/publisher identity is retained by ObjectRef copying and consumed by existing validators. The new capture uses the same caller-visible resolution as SHOW; it does not open a new transaction or select a different snapshot. DescribeView child-context cleanup and error propagation remain intact.
The new entry is plan-owned, deduplicated and released with the plan. No new worker, wait, retry, global cache or cross-request description owner is introduced. Missing targets continue to fail rather than yielding stale/empty metadata. Already-materialized cursors are outside this dependency-capture change; the broader cursor/authorization/snapshot matrix is not newly proven by this PR.
Independent QA. On Darwin/arm64, Go 1.26.4 with verified matching native inputs:
TestShowColumnsTracksTargetDependencypassed (all six subtests), including FULL/LIKE/WHERE, copy/wire/PREPARE propagation, View source retention and ordinary SELECT control.TestViewDescriptionPublicSQLpassed, including the PR's two-session table -> View -> table replacement and missing-target checks.- I extended that same isolated fixture with an adjacent challenge: after the missing-target error, recreate the target and reuse the same prepared handles; then CREATE/DROP a unique index while keeping the target table itself. Binary PREPARE, SQL PREPARE and COM_QUERY all recovered and refreshed SHOW's Key from empty -> UNI -> empty. The complete test passed in 12.14s; the replacement/challenge subtest took 0.23s. Reviewer additions remain local and do not modify this PR.
Reused CI run 36417143965 after checking its head. The UT checkpoint confirms successful planner shards and actual upgrade-package execution, not just compilation. The compose BVT log confirms view_metadata_on_demand.sql ran 30/30, zero failed/ignored/abnormal, in 0.874s. The author also reports full owning-package validation and two normal BVT comparisons with teardown on the same instance.
Engineering/performance. The production change is +5/-1 lines. Ordinary-table SHOW adds one dependency and one corresponding validation lookup; it does not invoke the View binder for ordinary tables or disable general SELECT caching. The tests reuse existing planner/public-SQL/BVT fixtures and add distinct reuse/identity oracles. No material performance regression or overengineering found; no throughput improvement is claimed.
There are no previous human or inline review comments on this PR. This approves the demonstrated SHOW dependency fix; #29006's broader acceptance map should remain open, as the PR description already states.
Merge Queue Status
This pull request spent 8 minutes 30 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. 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:
Related to #29006; part of #26227.
Scope was revalidated against the approved on-demand View metadata design merged in #29139. This PR fixes a demonstrated stale-metadata path under that design; it does not implement the original durable authority/lease/recovery checklist or automatically close #29006.
What this PR does / why we need it:
SHOW COLUMNSrecords its target as a catalog dependency only when the target is already a View. A prepared SHOW against an ordinary table therefore misses replacement of that target by a View and can keep reading persisted View columns instead of using on-demand binding.Reproduced through two real SQL sessions:
VARCHAR(5).VARCHAR(60).VARCHAR(5), whileinformation_schema.columnsreports 60.Record the target dependency for every SHOW COLUMNS plan, preserving the existing View source dependencies. The existing prepared-plan and COM_QUERY validation paths then handle target identity/version changes. No new protocol fields, feature gates, background workers, leases, or global caches are introduced.
Tests cover ordinary/FULL/LIKE/WHERE plans, dependency copy/wire/PREPARE propagation, preservation of View source dependencies, and an ordinary SELECT control. The existing public SQL fixture now exercises binary and SQL PREPARE plus COM_QUERY across table → View → table replacement and rejects a missing target. The existing BVT adds a two-session SQL PREPARE regression.
Validation
Go 1.26.4, Darwin arm64, repository
mo-cgo-testwrapper:./pkg/sql/planand./pkg/tests/upgradesuites passed.TestViewDescriptionPublicSQLpassed after adding the row-error assertion.go vet, incremental golangci-lint v2.6.2 built with Go 1.26.4, andmake -j2 buildpassed.The on-demand design preserves the caller's visible catalog snapshot; it does not require retroactively invalidating an already-materialized cursor after unrelated DDL. This focused fix leaves shared barrier, recovery, and COMMIT protocols unchanged.