Repository navigation
fix: harden tenant view upgrades against legacy objects - #27299
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 complete on exact head 8b730aa. The error path now exits the tenant drain after one failed transaction and can only retry through the existing timer, while the healthy path still drains immediately and cancellation propagates into each transaction. The TABLE_CONSTRAINTS and KEY_COLUMN_USAGE migrations cover absent, legacy base-table, stale-view, and canonical-view states through ordered, transactional DROP TABLE / DROP VIEW / CREATE VIEW steps; failed steps remain retryable. DROP VIEW IF EXISTS on a base table plans an empty target, and the executor returns before any lock, catalog lookup, or mutation; strict DROP VIEW, missing objects, subscriptions, temporary objects, and the existing multi-name limitation retain their intended behavior. Affected-package tests passed, plus the new drain regressions under -race -count=50; independent final-gate race checks also passed. No blocking correctness, lifecycle, concurrency, or performance issue found.
aptend
left a comment
There was a problem hiding this comment.
Deep re-review of exact head 2404692 after merging current main. No blocking issue found.
The tenant drain now stops after an error and retries only through the existing timer while preserving immediate healthy draining and cancellation. The TABLE_CONSTRAINTS and KEY_COLUMN_USAGE migrations converge the absent, legacy-base-table, stale-view, and canonical-view states through transactional DROP TABLE / DROP VIEW / CREATE VIEW ordering. DROP VIEW IF EXISTS on a same-named base table plans the established empty-target no-op, while strict DROP VIEW still returns ErrBadView; the updated alter_view expectation matches that contract. The main merge did not reopen the previously reviewed lifecycle or DDL boundaries.
Fresh targeted tests pass for bootstrap, v4_0_5, v4_0_6, and planner behavior. The drain tests also pass under -race -count=50. git diff --check is clean. GitHub does not permit approving one’s own PR, so this is recorded as a COMMENT review rather than APPROVE.
Merge Queue Status
This pull request spent 25 seconds in the queue, including 3 seconds running CI. Required conditions to merge
|
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Refs #27287, #27288, #27289. Backport of #27299 to `4.2-dev`. ## What this PR does / why we need it: - Makes the `information_schema.TABLE_CONSTRAINTS` tenant upgrade converge when an older tenant contains a same-named base table. - Stops the tenant-upgrade drain loop on errors or cancellation instead of spinning indefinitely. - Makes `DROP VIEW IF EXISTS` a no-op when the resolved object is a base table, while preserving the error for `DROP VIEW` without `IF EXISTS`. - Enables and updates the related BVT regressions. This backport intentionally does not include the `v4_0_6` changes from #27299 because those upgrade entries are not present on `4.2-dev`. Validation: - `make thirdparties` - `GOWORK=off go list/build/vet/test` for `./pkg/bootstrap`, `./pkg/bootstrap/versions/v4_0_5`, and `./pkg/sql/plan` - Focused race tests, 100 repetitions each, plus full `./pkg/bootstrap` race test - `make build` - `drop_if_exists.sql`: 47/47 passed, 0 ignored - `alter_view.sql`: 100/100 passed, 0 ignored
…#27299) This fixes the tenant-upgrade failure chain triggered by legacy `information_schema` objects: - stop the current tenant-upgrade drain round on error and retry through the existing timer, while preserving immediate draining on the healthy path; - converge `TABLE_CONSTRAINTS` and `KEY_COLUMN_USAGE` from absent, base-table, or stale-view states through qualified `DROP TABLE`, `DROP VIEW`, and canonical `CREATE VIEW` statements; - make `DROP VIEW IF EXISTS` a safe no-op when the resolved object is a base table, while preserving `ErrBadView` without `IF EXISTS`; - add ordering/idempotency unit tests, planner regressions, and BVT coverage that verifies same-named tables/views and their data remain intact. Validation: - affected-package `go list`, `go build`, and `go vet`; - focused regressions and complete normal tests across `pkg/bootstrap`, `v4_0_5`, `v4_0_6`, and `pkg/sql/plan`; - each new drain test under `-race -count=100`, followed by the complete `pkg/bootstrap` package under `-race`; - real persisted-data upgrade from pre-conversion commit `7686f340df`, staged through official `v2.1.0`, `v2.2.0`, `v3.0.0`, and `v4.1.4` binaries, then this PR binary: all upgrade steps reached `state=2`, both retained tenants reached `4.0.6`, legacy `TABLE_CONSTRAINTS` base tables became canonical views, and tenant marker rows remained intact; - `zz_accesscontrol/create_account.sql`: 150/150 passed both before and after the upgrade; - `ddl/drop_if_exists.sql`: 35 passed, 12 case-marked ignored, 0 failed (100%). Approved by: @XuPeng-SH, @fengttt
…#27299) This fixes the tenant-upgrade failure chain triggered by legacy `information_schema` objects: - stop the current tenant-upgrade drain round on error and retry through the existing timer, while preserving immediate draining on the healthy path; - converge `TABLE_CONSTRAINTS` and `KEY_COLUMN_USAGE` from absent, base-table, or stale-view states through qualified `DROP TABLE`, `DROP VIEW`, and canonical `CREATE VIEW` statements; - make `DROP VIEW IF EXISTS` a safe no-op when the resolved object is a base table, while preserving `ErrBadView` without `IF EXISTS`; - add ordering/idempotency unit tests, planner regressions, and BVT coverage that verifies same-named tables/views and their data remain intact. Validation: - affected-package `go list`, `go build`, and `go vet`; - focused regressions and complete normal tests across `pkg/bootstrap`, `v4_0_5`, `v4_0_6`, and `pkg/sql/plan`; - each new drain test under `-race -count=100`, followed by the complete `pkg/bootstrap` package under `-race`; - real persisted-data upgrade from pre-conversion commit `7686f340df`, staged through official `v2.1.0`, `v2.2.0`, `v3.0.0`, and `v4.1.4` binaries, then this PR binary: all upgrade steps reached `state=2`, both retained tenants reached `4.0.6`, legacy `TABLE_CONSTRAINTS` base tables became canonical views, and tenant marker rows remained intact; - `zz_accesscontrol/create_account.sql`: 150/150 passed both before and after the upgrade; - `ddl/drop_if_exists.sql`: 35 passed, 12 case-marked ignored, 0 failed (100%). Approved by: @XuPeng-SH, @fengttt
…#27299) This fixes the tenant-upgrade failure chain triggered by legacy `information_schema` objects: - stop the current tenant-upgrade drain round on error and retry through the existing timer, while preserving immediate draining on the healthy path; - converge `TABLE_CONSTRAINTS` and `KEY_COLUMN_USAGE` from absent, base-table, or stale-view states through qualified `DROP TABLE`, `DROP VIEW`, and canonical `CREATE VIEW` statements; - make `DROP VIEW IF EXISTS` a safe no-op when the resolved object is a base table, while preserving `ErrBadView` without `IF EXISTS`; - add ordering/idempotency unit tests, planner regressions, and BVT coverage that verifies same-named tables/views and their data remain intact. Validation: - affected-package `go list`, `go build`, and `go vet`; - focused regressions and complete normal tests across `pkg/bootstrap`, `v4_0_5`, `v4_0_6`, and `pkg/sql/plan`; - each new drain test under `-race -count=100`, followed by the complete `pkg/bootstrap` package under `-race`; - real persisted-data upgrade from pre-conversion commit `7686f340df`, staged through official `v2.1.0`, `v2.2.0`, `v3.0.0`, and `v4.1.4` binaries, then this PR binary: all upgrade steps reached `state=2`, both retained tenants reached `4.0.6`, legacy `TABLE_CONSTRAINTS` base tables became canonical views, and tenant marker rows remained intact; - `zz_accesscontrol/create_account.sql`: 150/150 passed both before and after the upgrade; - `ddl/drop_if_exists.sql`: 35 passed, 12 case-marked ignored, 0 failed (100%). Approved by: @XuPeng-SH, @fengttt
What type of PR is this?
Which issue(s) this PR fixes:
fixes #27287
fixes #27288
fixes #27289
What this PR does / why we need it:
This fixes the tenant-upgrade failure chain triggered by legacy
information_schemaobjects:TABLE_CONSTRAINTSandKEY_COLUMN_USAGEfrom absent, base-table, or stale-view states through qualifiedDROP TABLE,DROP VIEW, and canonicalCREATE VIEWstatements;DROP VIEW IF EXISTSa safe no-op when the resolved object is a base table, while preservingErrBadViewwithoutIF EXISTS;Validation:
go list,go build, andgo vet;pkg/bootstrap,v4_0_5,v4_0_6, andpkg/sql/plan;-race -count=100, followed by the completepkg/bootstrappackage under-race;7686f340df, staged through officialv2.1.0,v2.2.0,v3.0.0, andv4.1.4binaries, then this PR binary: all upgrade steps reachedstate=2, both retained tenants reached4.0.6, legacyTABLE_CONSTRAINTSbase tables became canonical views, and tenant marker rows remained intact;zz_accesscontrol/create_account.sql: 150/150 passed both before and after the upgrade;ddl/drop_if_exists.sql: 35 passed, 12 case-marked ignored, 0 failed (100%).