Skip to content

fix: refresh persisted collation metadata on tenant upgrade - #30485

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/0c5cabf6f0b3d9cd2440d68d76581cf8c9c223801078f67d7fb47a43ef711528
Oct 17, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/develop/0c5cabf6f0b3d9cd2440d68d76581cf8c9c223801078f67d7fb47a43ef711528

Conversation

@iamlinjunhong

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:

What this PR does / why we need it:

Existing tenants can retain empty or outdated information_schema.COLLATIONS data while SHOW COLLATION reads the current supported list. Fresh initialization already populates the table, but the only refresh was in the old 4.0.6 migration. In particular, tenants at catalog version 4.0.13 can retain six rows after native Unicode support expanded the advertised list to eight.

Add a forward 4.0.16 tenant migration, gated on protocol 118, that checks the row count and all seven metadata fields against the canonical definitions. It replaces stale rows inside the existing upgrade transaction and skips replacement when the data already matches. The old and new migrations share the exact completion predicate. Work is bounded by the small metadata table and occurs during upgrade.

Regression coverage uses the existing single-CN SQL fixture and the real MySQL frontend and tenant-upgrade selection. It checks fresh system/new tenant results, legacy six-row and empty tables, full SELECT/SHOW parity, each stale metadata field, duplicate rows, idempotence, account isolation, and rollback plus retry after an injected insert failure. The failure case verifies that the real DELETE rolls back and the tenant version remains unchanged.

Validation (Go 1.27.1, macOS arm64, CPU native libraries):

  • Full affected packages passed with the repository CGo wrapper: pkg/util/sysview, pkg/bootstrap, pkg/bootstrap/versions/v4_0_6, and pkg/bootstrap/versions/v4_0_16.
  • mo-cgo-test -v -count=1 -timeout=20m -run '^TestCollationsMetadataUpgrade$' ./pkg/tests/sqlintegration passed all 13 subtests. Scenario execution took 1.08 seconds; the package took 38.8 seconds including cluster admission and startup.
  • Incremental configured lint across the five changed packages reported 0 issues; formatting, diff checks, and native provenance verification passed.

CI is pending. Leave #30469 open for the reporter to verify after merge.

@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 of aefa885 against b111224. No blocking finding.

The forward 4.0.16 tenant migration is necessary: changing only the old 4.0.6 step cannot repair tenants that already passed it. The implementation uses the existing UpgradeEntry/tenant transaction/version-selection owners, derives both population and completion checks from the canonical collation definitions, and replaces the old predicate implementation with delegation to that same owner. No separate registry, recovery state, storage or query execution path is added.

Reviewed all eight changed files: implementation +153/-27; Go tests +408/-1; no documentation changes. Most tests exercise real behavior through the shared single-CN fixture, frontend SELECT/SHOW and MaybeUpgradeTenant, with an independent expected set. They cover six-row and empty historical tables, all seven stale fields, same-count duplicates, account isolation, idempotence, and rollback/retry after the real DELETE succeeds and INSERT fails. The smaller unit matrix covers protocol and SQL failures and result cleanup. One fixture is shared across the scenarios.

The metadata replacement and tenant-version advance remain in the existing transaction; failures are returned to its rollback owner. Existing protocol-118 compatibility is retained. I also traced the actual login entry: it bypasses a tenant newer than the serving CN, so an isolated call to the internal version checker is not evidence of a normal old-CN login regression.

Performance impact is confined to the one-time tenant migration over the small metadata table. Already-matching rows avoid DELETE/INSERT, and ordinary execution adds no per-row work. I found no demonstrated material performance regression.

Validation: exact-head build, UT/race, coverage, SCA and enabled BVT jobs pass in run 39042926996. The UT log and attempt-2 summary show TestCollationsMetadataUpgrade running and the owning sqlintegration race batches/package finishing successfully. Reviewed the author's additional 13-subtest local run and full affected-package results; I did not rerun those integration tests locally. No outstanding human review comments were present.

Approving this revision; the linked issue can remain open for reporter verification as described.

@mergify mergify Bot added the queued label Oct 17, 2026
@mergify

mergify Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-17 18:17 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-10-17 20:09 UTC · at a8be04735bcf6d2a7aa48d464f76c0b13c691ef5 · squash

This pull request spent 1 hour 52 minutes 5 seconds in the queue, including 54 minutes 19 seconds running CI.

Required conditions to merge

Copy link
Copy Markdown
Contributor

独立实测:main a8be04735bcf6d2a7aa48d464f76c0b13c691ef5 的四个完整归属包392事件通过,真实MySQL/实际tenant-upgrade selector普通和race各14事件通过;旧6行/空表、七字段、重复、幂等、账号隔离及DELETE后INSERT失败回滚/版本不推进/重试均通过。独立旧目录探针也从4.0.6+空表实际升级到4.0.16并恢复与SHOW一致的8行。

4.2-dev 35273bcd6a5cfa9468bcf7ca4031fe17560b5ab1 仍实际复现原问题:新租户SELECT为0行,SHOW为12行。 #30469保留开发指派,不把main-only修复当作整个报告已解决。完整证据、命令及迁移回放资格限制:#30469

未做旧二进制滚动升级、全仓库CI或完整MySQL collation兼容认证。

This branch was previously deployed

1 inactive deployment
ci — 91e245a0 Deployed Oct 17, 2026 by mergify[bot]
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 kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants