Skip to content

[4.2-dev] test: sync publication commits before cross-CN ALTER - #33400

Merged
XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
XuPeng-SH:fix/publication-lock-sync-42
Nov 27, 2026
Merged

XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
XuPeng-SH:fix/publication-lock-sync-42

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Test and CI

Which issue(s) this PR fixes:

Related to #32744.

What this PR does / why we need it:

TestAlterPublicationExplicitTargetLockScope/singleton created a publication on CN0 and immediately tried to alter it on CN1. In CI, CN1 returned publication 'scope_singleton' does not exist before reaching the lock wait the test was checking. Failed Ubuntu/x86 UT.

Synchronize the CREATE commit across both CNs before taking the publication lock and starting ALTER. Check that both CNs were synchronized. The existing lock ordering and assertions remain in place for both the wide and singleton cases.

Validation

  • Linux x86-64 with Go 1.26.6. Both wide and singleton passed two runs of the focused -race test with the matrixone_test tag.
  • Incremental SCA for ./pkg/tests/issues/isolated passed formatting, diff check, go vet, pinned molint, and golangci-lint (0 issues).

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

@mergify mergify Bot added the kind/test-ci label Nov 27, 2026
@matrix-meow matrix-meow added the size/XS Denotes a PR that changes [1, 9] lines label Nov 27, 2026
@XuPeng-SH
XuPeng-SH merged commit 0e56874 into matrixorigin:4.2-dev Nov 27, 2026
18 of 20 checks passed
@mergify

mergify Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

XuPeng-SH added a commit that referenced this pull request Dec 1, 2026
…32824)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Addresses #32814 on `4.2-dev` within the scope in #32886. The
schema-rebuild fix shipped separately in v4.2.9 (#32887).

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

- Resolve ENUM assignment using the destination column's ordered domain
and effective collation. Copying binary `ENUM('A','a')` into
`ENUM('a','A')` stores `A` at ordinal 2 and `a` at ordinal 1. Numeric
conversion after GROUP BY recovers ordinals with the source domain's
collation.
- Normalize newly declared, explicitly collated ENUM labels before
encoding. CREATE, ADD, MODIFY and CHANGE trim only trailing ASCII spaces
and reject duplicate labels using the assignment collation. Partition
children use the normalized parent type. Typed reconstruction and bare
ENUM authoring preserve their existing rules.
- Carry explicit assignments through planning, typed catalog
reconstruction, bulk input, and ALTER COPY. SHOW FULL COLUMNS and
INFORMATION_SCHEMA.COLUMNS expose the effective explicit collation. The
4.0.6 offset-6 upgrade refreshes persisted COLUMNS views for existing
tenants. On retry, the migration checks the catalog’s lowercase view
name and retains an already-current definition.
- Keep legacy ENUM lookup and DUMP/LOAD TABLE v1 hashes. DUMP and LOAD
reject typed ENUM columns at schema admission because v1 hashes do not
encode their assignment identity. An old archive's `create_sql` records
the original statement, which can contain a collation the original
version ignored.
- Reconstruct checkpoint DDL from the persisted type. DDL-only export
retains the collation. Single-table and batch LOAD DATA scripts reject
typed ENUM before exporting CSV because a numeric-looking member can be
confused with an ordinal.

- Reject source tables with explicitly collated ENUM columns when
initializing a MatrixOne or MySQL CDC SQL sink. The existing serializer
quotes an ordinal, so a target ENUM can interpret it as a
numeric-looking member label. Admission records a permanent diagnostic
on the source table before target schema or data changes.

## Verification on the rebased 4.2-dev head

Head `d9d8fcbd71` is based on `6afdb0cbb9`. The original assignment case
still stores `A / 2` and `a / 1` across reordered binary domains.

- The previous PR head stored `h / 8` via INSERT and `j / 10` via LOAD
DATA for the same string `'010 '`. The new MySQL-wire regression also
failed on the rebased control `6e95873f54`. Both writes now store `h /
8` for binary and general_ci columns. Numeric-looking labels take
precedence, strict imports reject invalid ordinals atomically, and
legacy CSV still reads `'010'` as decimal 10 and accepts zero. [Review
finding](#32824 (review))
- The same 134,577,988-byte file was imported with parallel mode enabled
and disabled. Both stored 10,923 rows of `h / 8`, 10,923 of `j / 10`,
and 10,922 of the declared label `0x2 / 1`. In five paired parser
microbenchmarks, a hexadecimal fallback (`'0x8 '`) went from two heap
allocations per cell to zero. Ordinary labels and decimal input stayed
at zero.
- The rebase keeps #32497's shared ALTER COPY key check and CDC
cancellation context. COPY index lifecycle and the ENUM restart test
passed over MySQL TCP. A live MatrixOne CDC sink recorded a permanent
error for an explicitly collated ENUM before creating its destination
database. A bare ENUM replicated as `b / 2`.
- The candidate opened a v4.2.8 cold backup and the stopped data
directory from the official v4.2.9 writer. The catalog moved from
4.0.6/5 to 4.0.6/6. Reopening preserved legacy bytes and ordinals,
including a valid empty label and the error ordinal. After the v4.2.9
upgrade, new binary columns retained the reordered assignment before and
after restart.
- All 11 owning Go packages passed their short suites. `types`,
`external`, `plan` and `cdc` ran in full under `-race -short`. The ENUM
wire and restart suite also passed under `-race` and independently with
scoped coverage instrumentation. `go vet` and incremental golangci-lint
passed across all 21 changed Go packages, with zero incremental lint
issues. The repository-pinned molint reported the same nine existing
`recover()` diagnostics on the clean base and the candidate.
Regenerating the plan protobuf from the merged schema reproduced the
committed file byte for byte.
- Nine BVT fixtures passed 888 statements with values compared and two
configured skips. With strict JDBC metadata enabled, 883 passed and the
five failing system-variable column headers matched the clean
`6afdb0cbb9` baseline exactly. All row values matched.

<details>
<summary>Earlier assignment, upgrade and benchmark results</summary>

This round verified `75bc4698f8` on base `167a1a9199`. The
conflict-update control is `0e18d0e28d`, the original PR rebased onto
that base. The execution-plan comparison uses its subsequent revision
`fbd0529ae2`.

- INSERT, UPDATE and duplicate-key updates now use the same assignment
builder. When the ordered domain and collation agree, the planner copies
the ordinal. For differing domains it binds one typed conversion using
the source ordinal, source members and destination lookup. Over MySQL
TCP, `EXPLAIN VERBOSE` went from two references to the same source
column inside a CASE to one reference in that conversion. Copying 65,536
alternating binary labels produced exactly 32,768 rows each at `41 / 2`
and `61 / 1` (hex bytes / ordinal).
- SQL regressions check NULL, the error ordinal zero, a valid empty
member, statement rollback and IGNORE when the destination cannot accept
a source label. The original two-, three- and four-argument lookup
expressions also execute over MySQL TCP.

- Reproduced two conflict-update failures over MySQL TCP on the control.
A literal `e='A'` failed with error 20203. Assigning
`e=VALUES(incoming)` copied ordinals across differently ordered binary
domains, silently interchanging the labels. The final head binds the
ordinary and duplicate-key assignment paths to the destination ENUM
definition. Literal, prepared, incoming-column, ordered existing-column
and DEFAULT assignments passed, including full-statement rollback on a
bad label. This also covers the ENUM portion of #33281.
- The types package owns scalar and indexed label resolution. DDL
duplicate checks and the planner's projected-order reversibility check
use the same member keys. Constant vector domains and collation tags are
validated once per batch. Tests cover Unicode weights, malformed UTF-8,
numeric-looking labels, legacy narrowing and invalid collation tags
under IGNORE.
- The official Linux/arm64 v4.2.9 binary (`6c05e42`) wrote `61 / 1` for
both differently cased source labels. A stopped upgrade using its data
directory moved an existing tenant from catalog 4.0.6/5 to 4.0.6/6.
Previously stored `6120 / 1` and `61 / 2` rows survived upgrade, ALTER
COPY and restart. Copying the released source to a newly declared binary
destination stored `41 / 2` and `61 / 1` before and after restart. A
separate restored v4.2.8 cold backup retained ordinals 2, 0 and 3,
including both empty-display cases, and retained the legacy lookup on a
subsequent write.
- All 11 owning Go package suites passed with `-short
-tags=matrixone_test`. Targeted `-race` tests covered assignment, the
MySQL TCP restart test, the composite index regression and CDC sink
admission. The restart test also passed with scoped coverage
instrumentation. The four changed BVT fixtures ran with the Compose CI
runner options and passed 530 assertions with two configured skips. Five
further BVT fixtures covering ENUM domain round trips, ENUM and SET
index maintenance, SET and geometry passed 358 assertions. Incremental
static analysis reported zero issues across the 22 changed Go packages.
Plan protobuf regeneration was verified on `fbd0529ae2`; its schema and
generated code are identical on this head.

The following medians compare five alternating runs of the text lookup
at `0e18d0e28d` and `fbd0529ae2` on the same Darwin/arm64 host with Go
1.26.4 and one CPU. The workload assigns unaccented uppercase inputs to
accented general_ci members. The large batch includes index
construction.

| Rows / labels | Control time per batch | Shared lookup time per batch
| Heap allocations per batch |
| --- | ---: | ---: | ---: |
| 1 / 8 | 283 ns | 163 ns | 9 → 0 |
| 16 / 8 | 2.76 µs | 1.60 µs | 88 → 0 |
| 1,024 / 64 | 45.2 µs | 35.6 µs | 1,094 → 68 |

### Additional validation on earlier revisions

- Released v4.2.8 and v4.2.9 reproduced the original assignment error.
Earlier stopped upgrades from both releases preserved existing ENUM rows
and lookup behavior.
- The stopped-upgrade validation used an actual v4.2.9 offset-5 catalog
with an existing tenant. The stopped upgrade refreshed COLUMNS at offset
6, preserved legacy bytes and ordinals, and reports both explicit
collations. The actual v4.2.9 full v1 archive restored into a legacy
table; the explicit-collation target was rejected and remained empty.
- The rebuilt checkpoint CLI read on-disk data. SHOW CREATE and DDL-only
preserved the member list and collation. CSV exported the original
ordinals, and both single-table and database restore scripts refused the
ambiguous load before output creation.
- Local race tests passed for the affected packages, including planner,
partitionservice, bootstrap and the MySQL-wire regression. The latter
covers partitioned assignment, padded ADD and MODIFY, failed duplicate
reauthoring, grouped numeric conversion, metadata, DUMP/LOAD admission
and catalog reopen. The pre-CDC head passed repository SCA.
- The four BVT fixtures affected by the updated COLUMNS metadata passed
locally (530 assertions, two configured skips). This covers the width
and view definition mismatches in the prior [Compose Pessimistic
job](https://github.com/matrixorigin/matrixone/actions/runs/45945393691/job/140331714011)
and [Compose Proxy
job](https://github.com/matrixorigin/matrixone/actions/runs/45945393691/job/140331713990).
Hosted CI on the new head runs separately.

- Live MatrixOne CDC reproduced the source label/ordinal `a / 2`
arriving as `2 / 3` on the preceding head. On the new head, the typed
tasks reported permanent table errors. An existing destination row kept
its original label/ordinal and a fresh destination database was not
created. The bare ENUM control still replicated. The CDC and frontend
owning suites passed with `-race -short -tags matrixone_test`.
Incremental SCA reported zero issues across the complete rebased diff.

- The embedded ENUM recovery test gives each cluster start its own
bounded SQL context. The previous [coverage
failure](https://github.com/matrixorigin/matrixone/actions/runs/45963415497/job/140392146674)
expired the original SQL context while the cluster recycled. The test
still performs a full restart and checks persisted labels, ordinals, and
write lookup.
- At `0cfd6e26e8`, the entire MySQL-wire ENUM test passed locally under
`-race` and independently under `-covermode=set` with scoped
instrumentation. Incremental SCA was clean against `4.2-dev` at
`0e568746d2`. The rebase includes the separate publication-test fix in
#33400. Hosted checks run on the new head.

<details>
<summary>Released-catalog upgrade and retry evidence</summary>

Stopped v4.2.9 Linux x86-64 binary `6c05e42` and started candidate
`388aac15c1` with the same launch configuration and data directory. The
release executable SHA-256 was
`d76fcc947ee73bc8a6ada94c437910c40a12d52af1a67d55ad0d2708f51d79e4`.

The existing tenant saved `ENUM('a ','a') COLLATE utf8mb4_bin` with
declared members as understood by the release. Seeded ordinals through
both numeric and text inserts. `SELECT id, HEX(CAST(e AS CHAR)), e+0
FROM legacy ORDER BY id` returned the same rows before upgrade, after
upgrade, and after restart and manual retry.

| id | HEX | ordinal |
| --- | --- | --- |
| 1 | 6120 | 1 |
| 2 | 61 | 2 |
| 3 | 6120 | 1 |
| 4 | 61 | 2 |

`CREATE TABLE inherited LIKE legacy`, INSERT SELECT, unrelated ALTER
COPY and additional text inserts preserved these same member mappings. A
new general_ci column exposed `utf8mb4_general_ci` and stored `'A '` as
byte `61` at ordinal 1.

| State | Ready catalog | System COLUMNS rel_id | Tenant COLUMNS rel_id
|
| --- | --- | --- | --- |
| Released | 4.0.6 offset 5 | 272495 | 272613 |
| Candidate after stopped upgrade | 4.0.6 offset 6 | 282925 | 282926 |
| After restart and manual retry | 4.0.6 offset 6 | 282925 | 282926 |

After candidate restart, `UPGRADE ACCOUNT 'enum_pad_tenant' WITH RETRY
2` and `UPGRADE ACCOUNT 'sys' WITH RETRY 2` each reached the COLUMNS
upgrade entry. The executor log contained no DROP or CREATE for COLUMNS
during retry. The before and after retry SQL transcripts, including SHOW
CREATE and relation IDs, compared byte-for-byte.

</details>

</details>

## Release boundary

Validate the stopped 4.2-to-main bridge and remaining recovery/transfer
paths, before releasing builds that author the new identity. Durable
database/table defaults, mixed-version use and metadata downgrade, typed
ENUM data restore and CDC support, and comparison/index-key changes
remain separate.

---------

Co-authored-by: Codex <[email protected]>

This branch was previously deployed

1 inactive deployment
ci — 4581705d Deployed Nov 27, 2026 by XuPeng-SH via Matrixone Utils CI / pr-size-label #66596
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/test-ci size/XS Denotes a PR that changes [1, 9] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants