Skip to content

fix(sysview): NULL charset/collation for binary-family columns and NULL UPDATE/CHECK time for fresh tables in information_schema - #31461

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-31160-31163-r20261027t051703
Oct 27, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-31160-31163-r20261027t051703

Conversation

@aptend

@aptend aptend commented Oct 27, 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 #31160
Fixes #31163

What this PR does / why we need it:

#31160 — information_schema.COLUMNS returned binary/binary in CHARACTER_SET_NAME/COLLATION_NAME for BINARY/VARBINARY/BLOB(-family) columns; per MySQL semantics these must be NULL/NULL (text family keeps utf8mb4). #31163 — freshly created tables showed non-NULL information_schema.TABLES.UPDATE_TIME/CHECK_TIME; these must be NULL (CREATE_TIME stays non-NULL; views keep NULL as before).

Implementation:

  • pkg/util/sysview/predefined.go — update the predefined information_schema.COLUMNS/TABLES view SQL (binary-family → NULL charset/collation; UPDATE_TIME/CHECK_TIME → NULL).
  • One legacy-view adaptation path (AdaptLegacyViewDefinitions, pkg/bootstrap/versions/information_schema_tables.go) shared by the planner snapshot path and bootstrap maintenance. Existing tenants keep their persisted view definitions, so updating only the predefined SQL (used at init) never repairs them.
  • Root cause completing the fix for tenants already at the final version (4.0.17): MaybeUpgradeTenant gates on version change, so no entry re-ran the CheckFunc, and InitSystemViews is sys-only. Added pkg/bootstrap/service_information_schema_columns_tables_maintenance.go: a post-upgrade maintenance pass that pages accounts (one txn per page), compares each tenant's persisted information_schema view definition by exact equality against the versioned-entry contract, and repairs only on mismatch. Error semantics (fail-fast, NOT per-account isolation): any account's CheckFunc/repair error aborts the pass — the page's single ExecTxn is rolled back, the account cursor is not advanced, and the error propagates to the caller (service_upgrade_tenant returns it, surfacing as an upgrade error; the same page is re-scanned on the next trigger/restart). The protocol-gate abort is the exception and is swallowed as a normal rolling-upgrade retry (returns nil). The only per-account skip is the AccountGone path (account deleted mid-page: its remaining entries are skipped while the rest of the page still commits). Idempotent across restarts (persisted definition converges ⇒ 0 repairs, verified).
  • BVT: new cases test/distributed/cases/information_schema/binary_charset_meta.sql and tables_time_defaults.sql; resynced dml/show/show.result and test/distributed/cases/zz_accesscontrol/account_restricted.result SHOW CREATE VIEW expected metadata to the new persisted view definitions (visibility/ACL semantics unchanged).

CI repair round (second commit, 739b885ba0):

  • CI run 40492305111 failed on tests that still expected the old binary/binary contract. Fixed here — product code unchanged:
    • pkg/tests/sqlintegration/database_defaults_test.go — scan charset/collation NULL-safe (NullString) and expect NULL after converting columns to binary.
    • pkg/tests/upgrade/view_description_test.go — subscription charset assertions made precise: before the per-tenant V109/V118 MODIFY_VIEW refresh, a subscriber still persisted on the historical V58/V100 i_s.COLUMNS text may legally project 'binary' for the binary family (historical projections are byte-stable by design in AdaptLegacyInformationSchemaColumnsDDL); the test asserts exact per-column equality with the publisher for all non-binary columns, constrains the raw (varbinary) column to the legal pre-refresh states ('binary' or the refreshed NULL) with charset/collation consistency, and asserts the native refresh converges the subscription to NULL (rewriting any historical 'binary' projection).
    • Four BVT goldens got surgical binary→null row updates only: charset_collation/charset_collation_defaults_conversion.result, dtype/binary_string_function_semantics.result, dtype/binary_string_result_domain.result, function/func_string_soundex.result.

Validation (evidence: /tmp/astra-meow-31160-31163-r20261027t051703/): the r4 local four-case mo-tester runs below (both the local -g -n runs and the strict META runs) used the private service running the binary built at the feature commit 1849c7d804 (build sha d9f908f50740; make-build-head.out). Separately: PR HEAD is 739b885ba0 on top of upstream d4ffbae43d; this second commit changes only 2 Go test files and 4 .result files — no product source. Other evidence items below carry their own binary identities as stated per item (the upgrade A/B binaries are from the 1231f06-era older tip; the earliest issue-specific BVT was recorded against the then-current fixed binary):

  • Upgrade A/B closure on PRIVATE ports 20000–20999, owned-PID lifecycle: old tenant already at v4.0.17 rendered RED (binary/binary; persisted def with 'binary' literals, upg-p1-binarylit.count=1; non-NULL times) → cross-version restart on fixed binary: maintenance repairs triggered exactly once (upg-p2-repairs.count=2), persisted def clean (upg-p2-binarylit.count=0), binary family now NULL/NULL, text utf8mb4 preserved, table times NULL, view stays NULL, new-tenant control NULL → second restart idempotent (upg-p3-repairs.count=0). Raw phase files: upg-p1-*, upg-p2-*, upg-p3-*, run-upg.sh. Honesty note: the raw combined run (upgrade-run6.log) exited non-zero due to a harness oracle bug (awk/grep direction on NULL counts), not an engine failure; the corrected verdict on the raw per-phase files is reported as such, not as an original rc=0 run.
  • Binary baseline honesty: the pre-fix/fixed A/B binaries were built from the 1231f06-era base / earlier tip, not this PR's final commit; the evidence is semantic (persisted i_s view definitions + frontend rendering path). The later upstream base move (8023763→00c103b6) touched only insert/load/JSON_TABLE binders (0 references to information_schema/sysview/SHOW CREATE), so it does not invalidate the A/B semantics.
  • Integration tests (mo-cgo-test, embedded clusters, raw rc): TestDatabaseCharsetInheritanceContract rc=0 (ut-charsetcontract.out); TestViewDescriptionSubscription rc=0, pass=1 fail=0 (ut-viewsub2.out). Static: STATIC_CHECK_PACKAGES='./pkg/tests/upgrade ./pkg/tests/sqlintegration' → 0 issues. rc=0 (static-cifix2.out), plus the 4-package static set rc=0 (static-post-rebase.out); -race bootstrap named set 6/6 pass, 0 data race (race-post-rebase.out).
  • mo-tester (private service, owned 14/14 listeners on 20000–20999 incl. HAKeeper 127.0.0.1:20201, trap-cleaned; per-run report copies under r4/report-*):
    • dml/show/show.test total 189 / success 189 / failed 0 (mt2-show.out); zz_accesscontrol/account_restricted.sql 126 / 125 / 0 failed / 1 ignored (pre-existing ignore flag, not counted as passed; mt2-acct.out).
    • Four repaired cases, each individually selected (non-zero totals), rerun locally via mo-tester run.sh -g -n (the actual CI runner invocation could not be extracted from the job logs; this is a local compare-new-results run, not a verified CI-mode-equivalent one): charset 121/121, binary_string_function_semantics 157/157, binary_string_result_domain 25/25, func_string_soundex 75/75 — all rc=0 (r4/ng-*.out).
    • Strict metadata mode (META): charset 118/121 rc=1, the other three 157/157, 25/25, 75/75 rc=0. The 3 charset failures are show full columns statements (rows 26/45/121); the only delta is the result-set Field type-annotation header Field[1,0,0] vs Field[12,-1,0] — row byte payloads are identical (evidence: r4/report-meta-charset/error.txt) and these exact statements passed in CI with the unchanged bytes, so the header annotations were deliberately NOT resynced (local mo-tester jar annotation drift). META is recorded here as rc=1 with this counter-evidence, not claimed as a pass.
    • Issue-specific BVT recorded earlier against the fixed binary: binary_charset_meta 10/10 rc=0, tables_time_defaults 9/9 rc=0.

Limitations: A/B upgrade binaries built on the older base (semantic-equivalence evidence as described); META charset rc=1 with the Field-annotation explanation above (not a green result); account_restricted keeps its 1 pre-existing ignored statement; no whole-directory or whole-repo stress rerun.

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

… and NULL UPDATE/CHECK time for fresh tables in information_schema
…tations with the NULL contract (matrixorigin#31160)

information_schema.COLUMNS renders NULL charset/collation for the binary
family after matrixorigin#31160. Align the suite with that verdict and with the
subscription refresh convergence semantics:

- sqlintegration: scan charset/collation as NULL-safe values and expect
  NULL collation after converting columns to binary.
- upgrade view_description: before the V109/V118 refresh a subscriber
  still persisted on the historical V58/V100 COLUMNS text may project
  'binary' for the binary family; assert per-column equality with the
  publisher for non-binary columns, constrain the raw column to the
  historical-or-refreshed projection with charset/collation consistency,
  and require the native refresh to converge to NULL.
- BVT goldens: update only the binary-family charset/collation rows
  (binary -> null) in charset_collation_defaults_conversion,
  binary_string_function_semantics, binary_string_result_domain and
  func_string_soundex; verified against the real engine in both
  metadata-strict and -g -n modes on the 31160/31163 branch.
@XuPeng-SH

XuPeng-SH commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 739b885ba0ace79cbf4a739dbc102ae182bbbef6

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 739b885ba0ace79cbf4a739dbc102ae182bbbef6

Assessment: approve

Reviewed the complete delta, linked issues, discussion, historical compatibility and tenant-maintenance lifecycle. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Passed focused tests and complete sysview, bootstrap and bootstrap/versions package tests.

  • Passed TestDatabaseCharsetInheritanceContract and TestViewDescriptionSubscription through the SQL frontend.

  • A diagnostic overlay verified fresh metadata and actual background repair of pre-fix definitions in a final-version tenant, preserving text metadata and post-DML timestamp behavior.

  • Bootstrap passed under the race detector; the new CAS test passed 100 repetitions.

  • Verified native provenance, golden changes, clean source and discussion-ledger completeness. Commands, source fingerprints, exit receipts and retained logs are reconciled in attempt-1/validation-audit.json.

Limitations:

  • Author validation artifacts were unavailable and were not counted as verified execution.

  • No mo-tester, multi-CN scale or cross-binary restart run was performed. The repair probe used historical definitions seeded into a single-binary cluster.

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

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

23 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Tue 27 Oct, 15:12 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 15:35 · af6e9a5

Reason

Pull request #31461 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Merge conditions: 2 of 3 met

This pull request

Condition Required by
✅ #review-threads-unresolved = 0 GitHub branch protection
✅ github-review-approved GitHub branch protection

The batch, tested in place

Condition Required by
❌ any of: check-neutral = CI Required, check-skipped = CI Required, check-success = CI Required GitHub branch protection

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

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

dequeued kind/bug Something isn't working size/L Denotes a PR that changes [500,999] lines

Projects

None yet

3 participants