Skip to content

fix(plan): validate catalog collation metadata before pruning - #29056

Merged
XuPeng-SH merged 24 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/28164-pr3-sql-semantics
Oct 16, 2026
Merged

XuPeng-SH merged 24 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/28164-pr3-sql-semantics

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

Which issue(s) this PR fixes:

Related to #28164; this is a partial catalog-admission repair. It does not close the original collation-aware UNIQUE/ODKU issue.

What this PR does / why we need it:

A constant projection such as SELECT 1 FROM t could prune a column carrying disabled native collation metadata before the final plan check. Validate the complete catalog schema before pruning in both normal table resolution and the catalog-only LIMIT 0 path, using the existing canonical RequireLegacyCollations owner. Preserve named-snapshot scope-error ordering and retain the final plan fence.

Legacy identities 0–3 and the already enabled UCA400 identities 9/10 (revision 1, physical format 0) remain allowed. Native 0900 identities 4/5 and physical key format 1 remain disabled. The tests cover allowed/rejected metadata, projection erasure, both resolver paths, rejection followed by compiler-context reuse, and snapshot-scope errors. Canonical SQL tests characterize existing MO behavior and verify rejected DDL leaves the legacy schema intact. The retired internal_collation_key remains unavailable; expression COLLATE erasure remains an existing compatibility gap.

Reviewed head: 0c9eaa559b8132fe9cc70bdee435f294c189c36c; frozen integration base: 0a4db0e6a6517e489a333ad9073dfcdc5d26aff4. The base-relative change comprises four files: planner admission, regression tests, and the canonical SQL/result pair. The library prerequisite #29054 merged at 22d43911d3f6c51872c1852340265a7d3f206925. Metadata prerequisite #29055 is included at 8542e40ed0cfa000abd1f09dc6051bfb7c173868 and precedes this PR; #29057 follows. Reconcile actual merged owners before merging or deployment.

QA required: yes — catalog admission across deployed caches, restored metadata, restart and mixed-version routing still needs deployment validation. Ready here opens maintainer review of this native-OFF repair; it does not authorize native activation, migration, deployment, or issue closure.

Validation at the reviewed head:

  • All five added test families selected and passed: 11 focused top-level tests and 3,656 tests in the owning planner package, with CGo/SIMD and count 1. The original unused-column test failed before the repair; the snapshot-ordering correction is covered at the final head.
  • Formal service build succeeded. Source/native provenance, staged libraries and the actual runtime loader match the tested binary (df193f1d00cc7108c60c5b1bf8c3443685677ffd9dc415a6fe128320df9dbc4a).
  • Canonical issue_28164_legacy_native_gate normal comparison passed 16/16 twice on the same instance, without failures, ignored or abnormal cases. The exact database was absent after each run; public-probe databases and the owned process group were removed. Fresh ISCP registration was observed.
  • Public probes passed 13/15 combined properties. Both UCA400 domains return the expected case/PAD SPACE equivalence classes, grouping, DISTINCT and original payloads. Their FORCE/IGNORE queries both use the existing safe table-scan fallback: two physical UCA index-path requirements remain UNMET. The planner intentionally excludes raw SERIAL lookup/covering reconstruction for these tagged UCA keys. A separate legacy control did exercise distinct table/index scans with equal results; it does not prove UCA index execution or MySQL general_ci parity.
  • Exact-head CI completed successfully, including CI Required, Linux UT/SCA, coverage and multi-CN BVT jobs. Skipped jobs are not counted as passes or deployment QA.

Known incomplete contracts remain explicit: original general_ci UNIQUE/ODKU returns three rows rather than the expected single updated row; VARCHAR utf8mb4_bin PAD SPACE and literal COLLATE identity also differ from the independent MySQL contract. Production-equivalent baseline execution confirms these are inherited; unchanged source ownership and the bounded admission change establish why they are separate from this repair. No expectations were changed to make them pass.

The first public wrapper attempt failed before canonical comparison and its overwritten current report was invalidated. The isolated recovery completed both comparisons; its public/wrapper exit 1 remains recorded because UCA physical-index requirements are unmet. Full compatibility, physical UCA index access, native 0900/format-1 activation and migration, mixed-version/stale-placement/durable-reload validation, and deployment QA are not complete.

@matrix-meow matrix-meow added the size/XXL Denotes a PR that changes 2000+ lines label Sep 17, 2026
XuPeng-SH pushed a commit that referenced this pull request Sep 20, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [x] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue #28164

## What this PR does / why we need it:

PR1 is the foundation of the staged #28164 implementation. It adds the
fixed Vitess v0.24.0 weight adapter and freezes the candidate V1 key
payload for the supported text semantics, while preserving the existing
tuple framing and legacy behavior.

Changes:
- pin Vitess v0.24.0 and its required module dependency closure;
- provide general-ci, utf8mb4_bin, utf8mb4_0900_ai_ci and
utf8mb4_0900_bin weight paths;
- validate UTF-8, bounded output, malformed payloads, ownership and
binary fast paths;
- record the independent MySQL oracle, golden bytes and tuple evidence;
- keep production admission disabled and make no SQL/index activation
change in this PR.

Dependency order:

1. This is the first implementation PR and is based on the #28164 design
in #28842.
2. PR #29055 (`codex/28164-pr2-metadata-tuple`, `d21a9b5e94`) depends on
this PR.
3. PR #29056 (`codex/28164-pr3-sql-semantics`, `0f06a4339e`) depends on
PR1 and PR2.
4. PR #29057 (`codex/28164-pr4-index-readwrite`, `2de15a3e98`) depends
on PR1–PR3.

The branch was extracted from stack baseline `3a50d04378`. Before this
update it was synchronized with the current GitHub target `main` at
`780ef933f2` via a merge; the PR diff remains scoped to the foundation
changes.

Validation:
- Independent PR1 `go list`, `go build`, `go vet` and package tests for
`./pkg/common/collation` and `./pkg/container/types`: PASS.
- MySQL 8.0.45 comparison and frozen-byte evidence: PASS for the codec
scope.
- Full SQL, index, persisted-filter, migration, mixed-version and
production-activation validation: NOT_RUN.
- BVT: N/A for this foundation layer because native semantics remain
rejected by default and no production SQL path is admitted here.
Consumer and integrated DML PRs must provide the runtime SQL evidence.

QA required: yes. QA must validate the complete #28164 chain, including
SQL semantics, DML/index behavior, persisted filtering,
migration/recovery and compatibility gates. This PR alone is not
production-ready; it is Ready for review while production activation
remains disabled.

Review and repair status (prior repairs are from the first-parent
history; current update is exact head
`013b9514ec57d7ed71054be8f46aa6e2d7c8d33b`):
- Fixed the confirmed SCA blocker by replacing the four production
`errors.New` sentinels in `pkg/common/collation/key.go` with repository
`moerr` sentinels; `make err-check` passes.
- Made the AWS SDK v2 dependency upgrade explicit and compatible:
`NewAwsSDKv2` selects `RequestChecksumCalculationWhenRequired` and
`ResponseChecksumValidationWhenRequired`, with a constructor regression
test.
- Fixed multi-object delete compatibility: when an endpoint rejects the
new SDK checksum with `MissingContentMD5`, `InvalidDigest`, `BadDigest`
or `InvalidRequest`, MatrixOne disables batch deletion and falls back to
individual `DeleteObject` calls. The HTTP regression verifies the first
batch rejection, all single deletes, and subsequent batch disablement.
- Narrowed the fallback comment so it does not claim general batch
atomicity.
- Reclassified tuple/decoder and Packer results in the design evidence
as historical integration evidence; PR2 must re-run them against its own
source. Current source hashes include the AWS deletion path and tests;
historical commands, hashes and raw logs are grouped separately.
- Local validation: current collation package list/build/vet/tests,
`make err-check`, focused fileservice tests including the
checksum-rejection fallback, JSON validation and base-to-head diff
check: PASS. Race/fuzz/benchmark reruns are explicitly marked NOT_RUN or
BLOCKED_ENVIRONMENT.
- Exact-head remote CI is re-running after this fix; full SQL/index,
persisted filtering, migration, mixed-version and QA validation remain
NOT_RUN for PR1.

Current PR1 LIKE boundary (exact head
`013b9514ec57d7ed71054be8f46aa6e2d7c8d33b`):
- Removed the unvalidated `UCA0900AIMatch` export and its direct Vitess
`Wildcard` call. No PR1 Go caller or matcher definition remains.
- Weight generation, collation comparison adapters, V1 payload bytes and
existing golden fixtures are unchanged. The evidence source hash for
`pkg/common/collation/uca0900.go` is updated to this source.
- LIKE is explicitly `NOT_RUN` in the evidence and belongs to PR3. PR3
must implement character-space `%`, `_` and escape semantics and add the
MySQL oracle matrix; weight equality/order is not LIKE evidence.
- A temporary fixed-Vitess probe observed `ss`/`ß` and reverse as true,
and 31 repeated `%a` as true while 32/33 returned false. This is
exploratory API-risk evidence only, not a PR1 or MySQL oracle PASS.
- Post-update local validation: collation `go list`, `go build`, `go
vet`, `go test -count=1`, `make err-check`, JSON/source-hash checks,
helper-reference search and `git diff --check`: PASS.

The PR is Ready for review. It remains a foundation PR and is not
production-ready.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Resolve add/add conflicts in the canonical collation admission test and
legacy native-gate BVT SQL/results, preserving upstream metadata semantics
and the PR's complete-metadata LIMIT 0 regression coverage.

Validation: planner/frontend builds passed before and after the merge;
frontend Limit0/LimitZero/Collation tests passed before and after the merge;
post-merge planner Collation/Limit/ViewMetadata tests passed. The frontend
complete-metadata admission regression and all seven subtests passed in
both runs. BVT was not run in this worker's scope.
All three PESSIMISTIC failures are stale PR-side result expectations:
CTAS from missing_src, SELECT from table02, and SELECT from system.table03.
Complete catalog resolution now produces the standard SQL parser missing-table
diagnostic after removal of the partial mo_columns LIMIT 0 shortcut.

Both merge parents retain the same SQL and result blobs, so these mismatches
are attributable to the PR rather than base drift or environment instability.
Update exactly the three error expectations; retain all SQL, empty-result
headers, CTAS rejection checks, and snapshot controls.

Validation: reproduced all three original mismatches and replayed the exact
PESSIMISTIC observations against the corrected expectations (3/3); diff check
passed. Local runtime BVT was not run because this scoped worktree lacks
mo-service, libmo, and mo-tester. New-head PESSIMISTIC verification remains.
@XuPeng-SH

XuPeng-SH commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 659b695e802dcd2bc15aefb450d68ae4da79175e

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: 659b695e802dcd2bc15aefb450d68ae4da79175e

Assessment: approve

Reviewed the complete delta and affected callers. Full resolution plus canonical validation closes admission before pruning, including the previously reported LIMIT 0 bypasses. The design removes shortcut state, preserves snapshot ordering and final validation, and has a measured, acceptable schema-dependent cost.

Model: gpt-6-astra / xhigh

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

Validation:

  • Verified clean frozen sources, compatible native provenance, diagnostic overlays, commands, exits and retained logs. Evidence mapping: /home/xupeng/.local/state/mo-bot/jobs/20c414bc66c58e9b1b5ac0da/attempt-1/evidence-audit.json.

  • Focused planner/frontend admission tests passed; receipt 1792142140719992514-3.json. Full planner package passed; receipt 1792142258879078168-3.json.

  • Merge-base control reproduced four expected failures: unused-column admission and three LIMIT 0 table/index metadata bypasses. Receipt 1792142327402875264-3.json; all corresponding candidate tests passed.

  • Public MySQL-protocol validation passed the canonical 17-statement comparison twice on one cluster, plus CTAS, missing-table errors, views, prepared LIMIT 0 and cleanup. Receipt 1792142263931005862-3.json.

  • Base/head planner benchmarks covered 8/128/512-column schemas and a no-table control. Wide-table planning medians increased approximately 5–9%; LIMIT 0 increased 7–12%, adding 19–47 allocations. Ordinary projection allocation counts were unchanged. Receipts 1792142361681276042-3.json and 1792142403458329684-3.json; details in performance.md.

  • Final evidence reconciliation passed: receipt 1792142563088760966-4.json. An earlier audit-only failure concerned the patch's terminal newline; its diagnostic log remains retained.

Limitations:

  • Public checks used the repository's embedded-cluster MySQL endpoint, not the mo-tester runner or deployment validation. Benchmarks exclude catalog I/O.

  • Approval covers the partial catalog-admission repair. Original UNIQUE/ODKU compatibility, COLLATE erasure, physical UCA index access, native activation and mixed-version/restart deployment QA remain outside this change.

  • Older-head author validation was not counted as current-candidate execution evidence.

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

mergify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-16 09:24 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-16 10:00 UTC · at b6c3f9d552e0700359b54795748077d1bf2acec6

This pull request spent 36 minutes in the queue, with no time running CI.

Reason

Pull request #29056 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.

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

  • Requeue this pull request

Copy link
Copy Markdown
Contributor

最近24小时合并项复核:main aa4b6eddfdad54d11be6fd75a5675eb9801f6690 的相关 catalog/collation 元数据与规划回归通过。原 #28164 的 general_ci UNIQUE 场景仍可先后插入 Apple、apple 而不报 1062,因此不能把元数据剪枝校验的修复当作该兼容性问题整体解决。该原始语义缺口继续由 #28164 跟踪,没有证据将其归因为本 PR 新引入。

This branch was previously deployed

1 inactive deployment
ci — b6c3f9d5 Deployed Oct 16, 2026 by mergify[bot]
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 kind/enhancement kind/feature size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants