Skip to content

fix: harden tenant view upgrades against legacy objects - #27299

Merged
mergify[bot] merged 4 commits into
matrixorigin:mainfrom
aptend:fix/tenant-upgrade-s1-27287-27289
Aug 19, 2026
Merged

mergify[bot] merged 4 commits into
matrixorigin:mainfrom
aptend:fix/tenant-upgrade-s1-27287-27289

Conversation

@aptend

@aptend aptend commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

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_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%).

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 aptend left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify

mergify Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-19 03:59 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-08-19 03:59 UTC · at 24046921c09798079999dcbbbcf153a72ab4bad0 · squash

This pull request spent 25 seconds in the queue, including 3 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)

@mergify
mergify Bot merged commit 32bcdab into matrixorigin:main Aug 19, 2026
26 of 27 checks passed
@mergify mergify Bot removed the queued label Aug 19, 2026
@aptend aptend mentioned this pull request Aug 19, 2026
1 of 7 tasks
aptend added a commit that referenced this pull request Aug 19, 2026
## 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
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…#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
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…#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
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…#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

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

4 participants