Skip to content

fix(sysview): expose native Unicode collation metadata - #29828

Merged
mergify[bot] merged 4 commits into
matrixorigin:mainfrom
daviszhen:codex/fix-unicode-collation-metadata
Oct 10, 2026
Merged

mergify[bot] merged 4 commits into
matrixorigin:mainfrom
daviszhen:codex/fix-unicode-collation-metadata

Conversation

@daviszhen

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

Related to #29206 (information_schema.COLUMNS metadata)

What this PR does / why we need it:

information_schema.COLUMNS returned NULL for columns using the native Unicode collation identities (utf8_unicode_ci and utf8mb4_unicode_ci). This made otherwise valid schemas look incomplete to ORM and metadata clients.

This PR:

  • exposes selectors 4/5 as utf8/utf8mb4 and utf8_unicode_ci/utf8mb4_unicode_ci;
  • adds a protocol-109 gate and a 4.0.14 tenant migration for already-upgraded tenants;
  • keeps the protocol-100 through 108 view definition frozen during rolling upgrades;
  • preserves historical COLUMNS view definitions when binding snapshots;
  • adds coverage for mixed-version admission, migration rollback/retry/idempotence, and SQL metadata results.

Validation was run in the local MatrixOne Docker build:

go test ./pkg/defines ./pkg/util/sysview ./pkg/bootstrap/versions/v4_0_10 ./pkg/bootstrap/versions/v4_0_14 ./pkg/bootstrap -count=1 -timeout=25m
go test ./pkg/frontend -run "TestCreateTenantInformationSchemaWaitsForAllProtocol(100|109)Peers" -count=1 -timeout=15m
go test ./pkg/tests/sqlintegration -run TestUnicodeCollationConsumerContract -count=1 -timeout=15m
go test ./pkg/tests/upgrade -run TestViewDescriptionSubscription -count=1 -timeout=20m

@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 →

@daviszhen

Copy link
Copy Markdown
Contributor Author

Reviewed head f1948cfe00320200501a91891a464ecb617e0703. Recommendation: request changes for one compatibility regression.

[P2] Keep the protocol-100 historical-view migration gate active

Location: pkg/util/sysview/predefined.go:282-283, interacting with IsCurrentInformationSchemaColumnsDDL at lines 306-307 and pkg/sql/plan/view_columns_history.go:71-72.

Changing InformationSchemaColumnsDDL to the native-Unicode definition also changes the meaning of the existing historical-query migration gate. IsCurrentInformationSchemaColumnsDDL now rejects the persisted V100 definition, even though that definition already implements the on-demand View-column migration.

For a tenant whose current COLUMNS definition is V100 (for example, an already-4.0.13 tenant waiting for the protocol-109 barrier during a rolling upgrade), querying a V58 historical snapshot now makes historicalViewColumnsSQL return the unadapted V58 SQL at line 72. That bypasses AdaptLegacyInformationSchemaColumnsDDL and can restore stale creation-time View-column metadata instead of describing the View against the historical source schema. The same tenant was considered migrated before this PR. Adding V100 recognition inside the adapter does not fix this path because the earlier gate prevents reaching the adapter.

I reproduced this by adding the following case to the existing TestHistoricalViewColumnsSQL table in an isolated temporary worktree:

{name: "protocol100 migration remains active before protocol109",
 current: sysview.InformationSchemaColumnsV100DDL(),
 wantResolve: true, wantAdapt: true},

The default historical definition in that test is V58. The new case fails: the returned SQL is the unchanged legacy definition, rather than AdaptLegacyInformationSchemaColumnsDDL(definition).

Please separate “has the protocol-100 on-demand View-column migration” from “has the latest native-Unicode projection”, and accept both V100 and V109 definitions for the historical adaptation gate. Keep the historical selector projection unchanged. Please cover this pre-109 case (including a cross-tenant snapshot); a useful integration assertion is the existing legacy-snapshot width check immediately after the V100 repair, before the V109 repair.

Validation: go test ./pkg/defines, ./pkg/util/sysview, ./pkg/bootstrap/versions/v4_0_10, ./pkg/bootstrap/versions/v4_0_14, and ./pkg/bootstrap passed locally, as did the focused frontend protocol-100/109 admission tests. Native dependencies were supplied from the existing local installation. The added planner regression fails as described above. git diff --check passed. Full SQL integration/upgrade tests were not rerun. CI is still running, with pr-size-label currently failed; this finding is independent of that check. No source changes were pushed and this comment does not change the formal review state.

@daviszhen

Copy link
Copy Markdown
Contributor Author

Updated the branch with commit ef4403f759 to address the historical-view migration gate comment.

Changes:

  • Added IsInformationSchemaColumnsMigrationDDL, which recognizes both the protocol-100 V100 definition (on-demand View-column migration with the historical selector projection) and the protocol-109 native-Unicode definition.
  • Changed historical snapshot binding to use this migration gate rather than requiring only the latest V109 definition.
  • Added planner coverage for V100-before-V109, including a cross-tenant snapshot case.
  • Added a real subscription snapshot assertion after the V100 repair and before the V109 refresh; the historical View still reports the source width correctly.

Validation in the local MatrixOne Docker image:

  • go test ./pkg/util/sysview -run "Test(AdaptLegacyInformationSchemaColumnsDDL|InformationSchemaColumnsDDL_MixedVersionSubscriptionViews)" -count=1 -timeout=15m
  • go test ./pkg/sql/plan -run TestHistoricalViewColumnsSQL -count=1 -timeout=15m
  • go test ./pkg/tests/upgrade -run TestViewDescriptionSubscription -count=1 -timeout=30m
  • relevant pkg/defines, bootstrap, and frontend protocol-gate tests
  • gofmt and git diff --check

All passed.

@daviszhen

Copy link
Copy Markdown
Contributor Author

Re-reviewed latest head ef4403f759f344d742283e550a18e1274f698e01, including the follow-up changes since my earlier review.

The previous P2 historical-snapshot regression is resolved. historicalViewColumnsSQL now uses the dedicated migration predicate accepting both V100 and V109 definitions, while the latest-projection predicate remains separate. This preserves the protocol-100 migration behavior before the protocol-109 refresh without changing historical charset/collation selectors. The added same-tenant and cross-tenant planner cases pass.

The real TestViewDescriptionSubscription upgrade test also passed locally, including the new historical-width assertion after the V100 repair and before the V109 refresh. This directly covers the migration window identified in my previous comment, as well as the rollback/retry/idempotence checks around both repairs.

Additional local validation passed using the existing native dependency installation:

  • Focused sysview selector, historical-template, and protocol-specific initialization tests.
  • Full TestHistoricalViewColumnsSQL.
  • pkg/defines, pkg/bootstrap/versions/v4_0_10, pkg/bootstrap/versions/v4_0_14, and pkg/bootstrap tests.
  • Frontend protocol-100/109 tenant-creation admission tests.
  • SQL integration TestUnicodeCollationConsumerContract, including the native Unicode charset/collation metadata assertions.
  • git diff --check.

No remaining blocking findings from this review. Recommendation: approve once the remaining CI checks complete successfully. My earlier request-changes recommendation for f1948cfe00 is superseded by this re-review. This comment does not submit a formal approval, and no source changes were pushed.

@daviszhen

Copy link
Copy Markdown
Contributor Author

Fixed the failing checks in c0819c9.

  • Updated the native-Unicode information_schema.COLUMNS golden output in dml/show and zz_accesscontrol/account_restricted (18351-byte definition, utf8/utf8mb4 Unicode collation branches).
  • Updated Test_createTablesInMoCatalogOfGeneralTenant to model a fully rolled-out cn-a:109 peer; mixed-version rejection remains covered by TestCreateTenantInformationSchemaWaitsForAllProtocol100Peers.
  • Focused frontend, sysview, planner, and upgrade tests pass locally.

@daviszhen

Copy link
Copy Markdown
Contributor Author

The latest UT Coverage attempt no longer fails on the COLUMNS fixtures. Its remaining failures are unrelated embedded-cluster flakes in pkg/tests/issues (TestIssue23861FulltextSnapshotRestore timed out during concurrent snapshot round 13; TestPrivilegeCacheTracksRemoteCatalogChanges lost the cluster while tearing down). Both tests pass locally in Docker. I reran the failed jobs (run 38047586618, attempt 2); UT Coverage is currently running.

@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 c0819c98543781f214da31f170a67f709d65392a against declared base/merge-base e5dd4724f782067e1c76c38c9d2f55cebceda4a9. No blocking findings.

Design and ownership:

  • The fix extends the existing sysview projection builder and keeps the four existing metadata branches and visibility rules. It introduces no parallel metadata store, execution path, or state machine.
  • A separate 4.0.14 migration is necessary for tenants already past 4.0.10. The V100 definition remains frozen; protocol 109 admission uses the existing common-protocol validator, both before tenant enumeration and before the entry writes. DROP/CREATE and tenant-version advancement remain owned by the existing transaction framework.
  • The historical binding predicate now distinguishes on-demand column migration readiness from the latest selector projection. V100 and V109 both qualify, while historical selector mappings remain unchanged. The previous P2 in issuecomment-6095695573 is addressed, including the pre-109 cross-tenant snapshot case. The later fixture/tenant-bootstrap corrections are present; there are no inline review threads outstanding.

Validation:

  • Verified exact-head CI run 38047586618: Ubuntu UT, coverage, SCA, and both PROXY/PESSIMISTIC multi-CN BVT jobs passed. UT logs explicitly show TestUnicodeCollationConsumerContract and TestViewDescriptionSubscription passing.
  • Independently extended the existing embedded subscription test temporarily, without changing production code or adding another cluster fixture. Both native collations return the expected identities through local tables, local Views, subscription tables, and subscription Views. A V100 snapshot retains NULL native-selector metadata after V109 migration. A binary prepared metadata query created before migration refreshes correctly afterward. The existing real-transaction rollback/retry/idempotence assertions also passed. The expanded test passed in 9.88s on Darwin/arm64, Go 1.27.1, through the repository CGo wrapper; reviewer-only changes were removed.
  • Audited implementation +191/-13, tests/results +339/-28, documentation 0/0 separately. The result-file changes are limited to the new selector arms and the corresponding definition length. New migration tests include real transaction failure injection, rather than relying only on the in-memory rollback simulation.

Performance: ordinary TP planning/execution and ordinary prepared-statement paths gain no new work in this patch. Added costs are the metadata CASE arms, V100 template construction during historical metadata binding, and the one-time gated tenant refresh. The prepared metadata invalidation case was exercised; no TP throughput benchmark or local mixed-binary rollout was run, so this is not a quantitative zero-regression claim.

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

mergify Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-10 13:41 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-10-10 13:45 UTC · at c0819c98543781f214da31f170a67f709d65392a

This pull request spent 4 minutes 7 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/native-dependency-check.yml without workflows permission
GitHub only lets Mergify write to .github/workflows/ with the workflows permission. An organization owner can accept Mergify's pending permissions at https://dashboard.mergify.com/orgs/matrixorigin/repositories.

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added dequeued and removed queued labels Oct 10, 2026
@mergify

mergify Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-10 15:08 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-10-10 15:08 UTC · at 8cc9167cb0a04479cd4c2f083aece5130f8c1946 · squash

This pull request spent 14 seconds in the queue, including 1 second running CI.

Required conditions to merge

This branch was previously deployed

1 inactive deployment
ci — 1df55e8d Deployed Oct 10, 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/enhancement 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