Skip to content

fix: consolidate safe 4.1 and 4.2 catalog upgrades into 4.0.7 - #31497

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-31490-safe-upgrade-407
Oct 28, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-31490-safe-upgrade-407

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 28, 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 #31490

What this PR does / why we need it:

Consolidates the unpublished main catalog steps into 4.0.7. Stopped released 4.1 and 4.2 deployments now execute the required catalog changes, including effects previously appended to an already consumed handler. Superseded intermediate handlers are removed; version, account and tenant-task tables remain the only durable progress owners.

Information-schema reconciliation now preserves logical identity and exact-object grants across upgrade, retry and recurring maintenance. Background, manual and login upgrades share one bounded tenant walker; caller-owned transactions retain rollback/commit ownership, and already-current accounts avoid replaying DDL. Column-only unsigned-flag backfills retain their raw catalog updates while the existing cache accepts only proven unchanged column projections, eliminating the upgrade's misleading missing-version errors without creating table versions or changing the protocol.

Upgrade prerequisites (4.1 / 4.2 to main)

  1. While the source cluster is still running, as sys administrator list all rows in mo_catalog.mo_cdc_task. Export any required CDC configuration and watermarks, then drop every existing CDC task in its own tenant using the source-version binary. Old tasks do not record the target identity required for safe resume, including paused or failed tasks. Verify the system-wide query returns no rows.
  2. Check system-account table snapshots whose names match the internal branch-protection pattern and whose kind is user. If ownership is ambiguous, determine it independently by snapshot UUID and supply the decision file described in the upgrade guide. Do not guess or delete snapshots. When there are no matching candidates, no decision file is needed.
  3. Stop and drain all old CNs and take a verified backup of the complete stopped deployment before starting any new-version service. Starting the new logservice may write records that 4.2 cannot read. If rollback is needed after that point, restore the complete pre-upgrade backup before restarting 4.2.
  4. Enable automatic catalog upgrade for the stopped migration. The per-object input limit defaults to 64 MiB; if an object exceeds it, provision memory and configure the same higher cn.upgrade-catalog-object-limit on all upgrading CNs before retrying.
  5. Recreate CDC tasks after upgrading against a clean or independently verified target; the old watermark alone does not prove safe resumption.

The new CN also rejects remaining legacy CDC tasks, but this is a last check after the logservice may already have started and does not replace pre-upgrade inspection. See docs/guides/upgrade-4.2-to-main.md for the SQL, decision format and operational details. FK reconciliation currently issues catalog queries per child table and may repeatedly scan the FK catalog; large FK counts can materially extend downtime, and bounded result pages do not bound scan work. The local 256- and 1,024-child fixtures do not establish a production time bound.

Historical restore limitations

  • System-account and cluster snapshot/PITR restores are rejected before mutations when the historical CDC watermark schema lacks columns required by the current version. A 4.2 system-account snapshot was verified to fail safely, leaving the current CDC schema and unrelated data intact; a current-schema snapshot restore remains usable.
  • A current-schema snapshot check does not quiesce running CDC or establish external target identity. Stop and drain CDC before account or cluster restore and rebuild or independently verify targets before resuming.
  • Iceberg metadata that cannot be safely rebound is rejected before restore mutations. Before restoring historical Iceberg snapshots/PITR, stop and drain Iceberg operations and verify with the remote catalog that commits with unknown outcomes have resolved. The current checks do not establish a cross-CN lifecycle fence or remote quiescence.

Validation

  • Final binary: stopped released 4.1.0 and 4.2.1 upgrades and restart passed. In each fixture, all 40 exact grant rows and 20 original logical object IDs survived; all four unsigned integer flags changed from 0 to 1, extrema and max-uint64 predicates remained correct, and negative inserts were rejected. Missing-version cache errors fell from 131 on the pre-fix 4.2.1 fixture to zero.
  • Final binary: released 4.2.6 with two CNs passed upgrade, unsigned controls, cross-CN writes, ADD COLUMN, same-name DROP/recreate and restart. Both CNs reached catalog 4.0.7; upgrade/restart logs contained zero unmatched-column errors.
  • Real-engine tests verify rollback before and after view replacement, orphan-maintenance retention, non-admin WITH GRANT OPTION forwarding and denial outside its original authority, and caller-owned migration rollback followed by a successful retry. Affected bootstrap/version/cache suites and selected embedded/dispatcher tests passed normally and with the race detector.
  • Recomputed complete delivery scope: 333 affected/reverse-dependent Go packages. Configured incremental lint, go vet, custom molint, formatting and repository err-check passed. Tools match the local Go 1.27.1 / macOS arm64 build. CI for the new commit remains separate.
  • Matched decoder microbenchmark: ~48 ns/op before and after, unchanged 192 B / 2 allocations. The conservative fallback adds measured work only on unmatched updates: about 0.30 ms for 128 cached columns and 1.94 ms for 1,024 cached columns with a 128-row update. Several pages repeat the prior-schema scan; these are local measurements, not production bounds.
  • Historical evidence on the prior candidate includes a real 130-account/two-CN SIGKILL recovery with exact task/counter coverage. Current walker normal/restart coverage is separately tested; the historical result is not a new-code large-topology pass.
  • Independent gpt-6.1-terra / max design and final review cover the full change map and review-fix delta. No unresolved material blocker remains in the final reviewed content.

Scope limits

Direct 3.x upgrades, unpublished main intermediate catalogs, downgrade and mixed-version operation are excluded. Existing older snapshots still require the ownership checks above. The existing 4.1-to-4.2 SQL semantic difference is preserved (for example, '1'||'2'=12 differs between those releases); catalog migration does not introduce a historical SQL execution mode. FK reconciliation retains its measured repeated-scan cost and can require substantial downtime. These tests are sampled compatibility/recovery evidence, not a guarantee for every production configuration.

@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 kind/bug Something isn't working kind/documentation Improvements or additions to documentation labels Oct 28, 2026
@XuPeng-SH

XuPeng-SH commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 11ba7240c4ae1125d2adcd8a5b2c92223647a770

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: 11ba7240c4ae1125d2adcd8a5b2c92223647a770

Assessment: request_changes

The consolidation and recovery ownership design is reasonable, and focused checks pass. Approval remains blocked by the explicit released-version upgrade validation requirement. This is a validation gap, not a demonstrated production defect.

Model: gpt-6-astra / xhigh

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

  • P2 docs/design/20261028-catalog-upgrade-407.md:65: Accepting the consolidated 4.0.7 migrations without the required stopped-upgrade validation from released 4.1.0 and 4.2.6.
    Impact: Compatibility with both persisted catalog layouts and equivalence to fresh initialization remain unverified. Issue #31490 demonstrates that reaching StateReady can still leave required columns absent. Provide or recover matching candidate results for both released-source upgrades, covering routines, FK/index behavior, user data, snapshots, supported historical restore and fresh-catalog equivalence. Existing qualifying runs can be reused; no committed proof artifact is required.
    Evidence: Issue #31490 and this design line explicitly require these upgrades. evidence.json.local_validation is empty. The PR reports a 4.2-dev run at 86a45d3, but no 4.1.0 result or qualified released-source/fresh-catalog comparison. TestCrossTargetUpgradeRecovery creates catalogs with the current binary and substitutes version handlers (pkg/embed/upgrade_recovery_test.go:109-150). Its successful receipt, attempt-2/checks/1793158585020286346-3.json, establishes recovery behavior, not released-catalog compatibility.

Validation:

  • Verified the frozen head/base, unchanged tracked source, identical prior-attempt patch and native provenance with 193 matching input hashes. Receipt/log reconciliation is retained in attempt-2/validation-audit.json; audit receipt checks/1793159159961120107-3.json exited 0.

  • Reused exact-head bootstrap/version suites: 187 top-level passes, no failures or skips. attempt-1/bootstrap-tests.log matches checks/1793157817871347695-4.json and its retained command script.

  • Executed 24 additional top-level tests through the supplied isolated executor, covering two-CN recovery/restart, migration paging, allocator restore, restore preflight, startup cancellation, local execution and result-limit rollback. All passed. Receipts 1793158484831360266-3, 1793158585020286346-3, 1793158692449419573-3 and 1793158776886133385-3 are mapped to retained logs in validation-audit.json.

  • Read the complete frozen discussion and linked issue. discussion-assessment.json covers both informational items; no substantive prior findings or rebuttals exist. Frozen CI supplies no completed released-upgrade validation.

Limitations:

  • No released-binary upgrade was executed during this review. Current-binary recovery fixtures do not close that requirement.

  • Full implementation acceptance remains open beyond this material gate: exhaustive removed-test oracle reconciliation, larger-page concurrent/unknown-commit fault coverage and independently qualified race/static checks are incomplete.

@XuPeng-SH

XuPeng-SH commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: aa97850419faaac21332b2025294d9be31fe68c3

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

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: aa97850419faaac21332b2025294d9be31fe68c3

Assessment: approve

The four prior test regressions and counter-owner documentation concern are resolved. The author’s specific released-upgrade results supersede the earlier absence-of-results finding. Review of the follow-up and unchanged migration closures found no actionable unresolved defect.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

Validation:

  • Eight focused tests passed, including all four prior failures and historical SQL/template controls.

  • Five complete owning-package suites passed: 227 top-level tests, no failures or skips.

  • Verified native provenance against 193 inputs; isolation preflight, formatting, diff and source-cleanliness checks passed.

  • Reconciled all 10 nonempty discussion items and removed-test coverage. Receipts and logs are recorded in /home/xupeng/.local/state/mo-bot/jobs/551d00c97ed982ae5cac9ac7/attempt-1/validation-audit.json.

Limitations:

  • Released-binary upgrades, broad race/static checks and benchmarks remain attributed author evidence; they were not independently rerun here.

  • Local execution used Linux/amd64 with Go 1.27.1. Frozen required CI was still pending.

  • Documented CDC/Iceberg restore prerequisites and FK scan-cost limitations remain applicable.

@XuPeng-SH
XuPeng-SH merged commit ea47345 into matrixorigin:main Oct 28, 2026
26 of 27 checks passed
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 28, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 28, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).

Repair the license-eye SCA findings from CI run 40773355581: correct the
Apache URL typo (LICENSE-2.2 -> LICENSE-2.0) in engine_orphan_gc.go and add
the standard Matrix Origin header to pk_move_pin_charge_test.go,
pk_move_rollback_index_test.go, and pk_move_shrink_boundary_test.go;
license-eye -c .licenserc.yml header check on all four files is 4/4 valid.
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 28, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).

Repair the license-eye SCA findings from CI run 40773355581: correct the
Apache URL typo (LICENSE-2.2 -> LICENSE-2.0) in engine_orphan_gc.go and add
the standard Matrix Origin header to pk_move_pin_charge_test.go,
pk_move_rollback_index_test.go, and pk_move_shrink_boundary_test.go;
license-eye -c .licenserc.yml header check on all four files is 4/4 valid.

Repair the Makefile err-check SCA finding from CI run 40776611402: the gate
rejects fmt.Errorf/errors.New text in non-test pkg code, and this branch's
new pk-move files carried 25 fmt.Errorf sites and one errors.New sentinel.
Convert them to moerr constructors; the three per-account reap wraps keep
inner-error identity for the fail-atomic ErrorIs assertions through a typed
dataBranchReapAccountError with Unwrap (message text unchanged). Also clear
the fourteen golangci-lint findings the same job reaches once err-check
passes: a govet nilness dead error branch in the logtailreplay change-handle
Next method, three ineffassign writes (two pk-move link walk fixtures, one
tombstone normalization-charge probe), two prealloc slice hints (reap rows,
link table-def columns), an SA6001 non-pointer map-key copy in the link
receiver, an SA9003 empty condition in the same-key replacement emission, and
six unused symbols (pkMoveLinkID, pkMoveLinkTxnIDUnknown, the stage-stub
commitTS field and isClosed method, the boundary fixture armWrites and
writePaths helpers).
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 29, 2026
…T, and full generated-column expressions

Consolidates the catalog metadata corrections for matrixorigin#30936, matrixorigin#30935 and
matrixorigin#30937 and rebases the stored-view repair onto upstream's consolidated
upgrade ladder (matrixorigin#31497).

Defect corrections (unchanged in substance from the reviewed rounds):

- information_schema.COLUMNS binds the label-aware metadata helpers:
  ENUM/SET character/octet lengths follow the declared labels
  (multibyte included) and leave numeric metadata SQL NULL for
  ENUM/SET, keeping ordinary types byte-stable.
- STATISTICS.SUB_PART and SHOW INDEX Sub_part return the numeric
  prefix length from mo_indexes.algo_params (mo_index_sub_part) and
  actual SQL NULL for non-prefix indexes.
- information_schema.COLUMNS.GENERATION_EXPRESSION returns the full
  expression; the varchar(500) view cast is removed.
- Fresh publication (bootstrap init, CREATE ACCOUNT, subscriptions)
  serves the corrected identities unconditionally; historical
  snapshot readers keep recognizing their recorded definitions.

Delivery vehicle, per approved design revision 12
(docs/design/20261026-declared-catalog-metadata-publication-and-repair.md,
sha256 47ebfe15a45940221c3d2d5ad6955e11a5c89a1a909fa9d4e382e1ac9db0a599):

- pkg/bootstrap/versions/v4_0_8 is the successor hop of the frozen
  4.0.7 stage: two idempotent legs on the upstream shared builder
  (COLUMNS gate 109; prefix-aware STATISTICS gate 41), protocol
  floor 118, offset len(tenantUpgEntries), a plain per-entry
  HandleTenantUpgrade (no paging), no cluster entries; registered
  after v4_0_7.Handler. The revision-9 v4_0_18 carrier is deleted.
- The four 4.0.7-literal admission guards in checkUpgrade are re-keyed
  onto the consolidated-line comparison and the registered frozen
  handle's identity (D11-1/D11-2): legacy CDC admission at route
  creation, recheck and recovery; the ready frozen-source validation;
  the interrupted offset-only route rejection - upstream's message
  texts, error types and pre-mutation ordering are unchanged.
- The on-demand tenant walks continue past the paged 4.0.7 stage to
  the final version before caching completion (D12-1/D12-2):
  MaybeUpgradeTenant resumes the register walk in one bounded
  service-owned transaction after the stage commits, UpgradeOneTenant
  no longer terminates at the frozen branch for accounts already at
  4.0.7, and both walks keep mo_account.create_version as the sole
  progress marker: a failure leaves the cache unset and resumes from
  the committed stamp.
- Oracles: the admission suite (CDC admission/rejection at the
  successor registration including the recovery path and direct
  succession, frozen-source and offset-only rejections at both the
  pre-mutation check and recovery validation), and the continuation
  suite at the real v4_0_7 plus v4_0_8 registration (late-login
  convergence with second-login idempotence, manual chaining, manual
  upgrade from an already-stamped 4.0.7 account, successor failure/
  retry without premature caching, and the no-successor-SQL-before-
  stage-completion ordering), plus the re-derived route/hop tests on
  the consolidated ladder.
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 29, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).

Repair the license-eye SCA findings from CI run 40773355581: correct the
Apache URL typo (LICENSE-2.2 -> LICENSE-2.0) in engine_orphan_gc.go and add
the standard Matrix Origin header to pk_move_pin_charge_test.go,
pk_move_rollback_index_test.go, and pk_move_shrink_boundary_test.go;
license-eye -c .licenserc.yml header check on all four files is 4/4 valid.

Repair the Makefile err-check SCA finding from CI run 40776611402: the gate
rejects fmt.Errorf/errors.New text in non-test pkg code, and this branch's
new pk-move files carried 25 fmt.Errorf sites and one errors.New sentinel.
Convert them to moerr constructors; the three per-account reap wraps keep
inner-error identity for the fail-atomic ErrorIs assertions through a typed
dataBranchReapAccountError with Unwrap (message text unchanged). Also clear
the fourteen golangci-lint findings the same job reaches once err-check
passes: a govet nilness dead error branch in the logtailreplay change-handle
Next method, three ineffassign writes (two pk-move link walk fixtures, one
tombstone normalization-charge probe), two prealloc slice hints (reap rows,
link table-def columns), an SA6001 non-pointer map-key copy in the link
receiver, an SA9003 empty condition in the same-key replacement emission, and
six unused symbols (pkMoveLinkID, pkMoveLinkTxnIDUnknown, the stage-stub
commitTS field and isClosed method, the boundary fixture armWrites and
writePaths helpers).

Repair the molint checkrecover SCA finding from CI run 40788517465
(SCA Test on Linux/arm64): the analyzer admits recover() only inside its
whitelisted functions, and the pk-move compaction wave collected worker
panics through an explicit recover() in
Transaction.compactDeletionOnObjsLocked (txn.go:3349). Move that collection
onto the ants pool's PanicHandler in a new unexported runCompactWave
helper: finishSlot runs exactly once per submitted slot and appends the
abort BEFORE Done releases the parent wait on every completion path, and
ants invokes the handler synchronously in the aborted worker's goroutine
while it recovers the panic (v2.12.0 worker.go), so the r26 review F1
contract — a panicking or unsubmittable worker fails the boundary
atomically before any provenance carry or object reclaim — keeps its
error-before-release ordering and identical "compaction worker
aborted/submit failed" messages without editing the external linter
whitelist. The compaction slot type moves to package scope for the
helper's signature. New txn_compact_wave_test.go pins the mechanism:
worker panics are collected exactly once, mixed success/panic waves
collect only the panics while slot-local errors stay on their slots,
closed-pool submissions fail instead of hanging the boundary, and empty
waves return cleanly; race battery, the r26 shadow-failure boundary
suite, and the full pk-move boundary regression stay green, and the
CI-pinned molint (go1.27.1 build) reports zero diagnostics on ./....
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 29, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).

Repair the license-eye SCA findings from CI run 40773355581: correct the
Apache URL typo (LICENSE-2.2 -> LICENSE-2.0) in engine_orphan_gc.go and add
the standard Matrix Origin header to pk_move_pin_charge_test.go,
pk_move_rollback_index_test.go, and pk_move_shrink_boundary_test.go;
license-eye -c .licenserc.yml header check on all four files is 4/4 valid.

Repair the Makefile err-check SCA finding from CI run 40776611402: the gate
rejects fmt.Errorf/errors.New text in non-test pkg code, and this branch's
new pk-move files carried 25 fmt.Errorf sites and one errors.New sentinel.
Convert them to moerr constructors; the three per-account reap wraps keep
inner-error identity for the fail-atomic ErrorIs assertions through a typed
dataBranchReapAccountError with Unwrap (message text unchanged). Also clear
the fourteen golangci-lint findings the same job reaches once err-check
passes: a govet nilness dead error branch in the logtailreplay change-handle
Next method, three ineffassign writes (two pk-move link walk fixtures, one
tombstone normalization-charge probe), two prealloc slice hints (reap rows,
link table-def columns), an SA6001 non-pointer map-key copy in the link
receiver, an SA9003 empty condition in the same-key replacement emission, and
six unused symbols (pkMoveLinkID, pkMoveLinkTxnIDUnknown, the stage-stub
commitTS field and isClosed method, the boundary fixture armWrites and
writePaths helpers).

Repair the molint checkrecover SCA finding from CI run 40788517465
(SCA Test on Linux/arm64): the analyzer admits recover() only inside its
whitelisted functions, and the pk-move compaction wave collected worker
panics through an explicit recover() in
Transaction.compactDeletionOnObjsLocked (txn.go:3349). Move that collection
onto the ants pool's PanicHandler in a new unexported runCompactWave
helper: finishSlot runs exactly once per submitted slot and appends the
abort BEFORE Done releases the parent wait on every completion path, and
ants invokes the handler synchronously in the aborted worker's goroutine
while it recovers the panic (v2.12.0 worker.go), so the r26 review F1
contract — a panicking or unsubmittable worker fails the boundary
atomically before any provenance carry or object reclaim — keeps its
error-before-release ordering and identical "compaction worker
aborted/submit failed" messages without editing the external linter
whitelist. The compaction slot type moves to package scope for the
helper's signature. New txn_compact_wave_test.go pins the mechanism:
worker panics are collected exactly once, mixed success/panic waves
collect only the panics while slot-local errors stay on their slots,
closed-pool submissions fail instead of hanging the boundary, and empty
waves return cleanly; race battery, the r26 shadow-failure boundary
suite, and the full pk-move boundary regression stay green, and the
CI-pinned molint (go1.27.1 build) reports zero diagnostics on ./....

Repair the six terminal failures of CI run 40797678570 (attempt 1),
triaged per failed-job terminal log into five PR-caused classes
(design r99): (A) the UT cascade (UT Test / UT Coverage on
Ubuntu/x86) from the on-demand tenant upgrade walk hard-breaking at
the frozen v4_0_7 handle in every case, so a 4.0.7-born tenant never
planned the remaining chain and the bootstrap stall starved
mo_task.sys_cron_task into the nil-deref cascade
(pkg/bootstrap/custom_upgrade.go, service_upgrade_tenant.go: the
frozen 4.0_7 hop now commits OUTSIDE the planning transaction
through at most one on-demand pass, and the chain re-plans from the
advanced create_version; the v4_0_8 embed fixture expectation
follows); (B) the multi-cn PROXY fulltext 300s watchdog hang from
fencing-retirement witness rounds firing for commits that never
wrote staged state, compounding into lockservice starvation (new
D219 pre-round gate in RunDataBranchFencingRetirementCS: exclusive
ledger-row-key grant first, then locked-view committed-link and
row_kind=0 retention-identity probes; neither present skips the
witness round, watermark fold and certification entirely); (C) the
61->63 mo_catalog table-count diffs in the sp_table, show,
database_statistics, information_schema, create_user_default_role,
restore_cluster_table, cluster_level_snapshot_restore_cluster and
clone_sys_db_table_to_new_db_table .result oracles from the two new
catalog tables; and (D) the TestGCFiles round-two false PASS from
the D121 live-reference guard filtering a re-used fixed
object-name set (round 2 now writes fresh names whose
distinguishing byte lands inside the ObjectName.String() key
window the guard compares). The merge/pick
provenance aborts on the pess compose job are PR-caused but did NOT
reproduce in sustained local replays - both suites run 100% green
(2008/2008 merge, 1721/1721 pick) on a local two-CN
pessimistic-RC cluster under DISK-V2 and MINIO storage shapes; the
leading hypothesis is CI-runner evidence starvation from the class-B
retirement storm, whose gate is the direct remedy, and the post-push
CI run owns the verdict.
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 29, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).

Repair the license-eye SCA findings from CI run 40773355581: correct the
Apache URL typo (LICENSE-2.2 -> LICENSE-2.0) in engine_orphan_gc.go and add
the standard Matrix Origin header to pk_move_pin_charge_test.go,
pk_move_rollback_index_test.go, and pk_move_shrink_boundary_test.go;
license-eye -c .licenserc.yml header check on all four files is 4/4 valid.

Repair the Makefile err-check SCA finding from CI run 40776611402: the gate
rejects fmt.Errorf/errors.New text in non-test pkg code, and this branch's
new pk-move files carried 25 fmt.Errorf sites and one errors.New sentinel.
Convert them to moerr constructors; the three per-account reap wraps keep
inner-error identity for the fail-atomic ErrorIs assertions through a typed
dataBranchReapAccountError with Unwrap (message text unchanged). Also clear
the fourteen golangci-lint findings the same job reaches once err-check
passes: a govet nilness dead error branch in the logtailreplay change-handle
Next method, three ineffassign writes (two pk-move link walk fixtures, one
tombstone normalization-charge probe), two prealloc slice hints (reap rows,
link table-def columns), an SA6001 non-pointer map-key copy in the link
receiver, an SA9003 empty condition in the same-key replacement emission, and
six unused symbols (pkMoveLinkID, pkMoveLinkTxnIDUnknown, the stage-stub
commitTS field and isClosed method, the boundary fixture armWrites and
writePaths helpers).

Repair the molint checkrecover SCA finding from CI run 40788517465
(SCA Test on Linux/arm64): the analyzer admits recover() only inside its
whitelisted functions, and the pk-move compaction wave collected worker
panics through an explicit recover() in
Transaction.compactDeletionOnObjsLocked (txn.go:3349). Move that collection
onto the ants pool's PanicHandler in a new unexported runCompactWave
helper: finishSlot runs exactly once per submitted slot and appends the
abort BEFORE Done releases the parent wait on every completion path, and
ants invokes the handler synchronously in the aborted worker's goroutine
while it recovers the panic (v2.12.0 worker.go), so the r26 review F1
contract — a panicking or unsubmittable worker fails the boundary
atomically before any provenance carry or object reclaim — keeps its
error-before-release ordering and identical "compaction worker
aborted/submit failed" messages without editing the external linter
whitelist. The compaction slot type moves to package scope for the
helper's signature. New txn_compact_wave_test.go pins the mechanism:
worker panics are collected exactly once, mixed success/panic waves
collect only the panics while slot-local errors stay on their slots,
closed-pool submissions fail instead of hanging the boundary, and empty
waves return cleanly; race battery, the r26 shadow-failure boundary
suite, and the full pk-move boundary regression stay green, and the
CI-pinned molint (go1.27.1 build) reports zero diagnostics on ./....

Repair the six terminal failures of CI run 40797678570 (attempt 1),
triaged per failed-job terminal log into five PR-caused classes
(design r99): (A) the UT cascade (UT Test / UT Coverage on
Ubuntu/x86) from the on-demand tenant upgrade walk hard-breaking at
the frozen v4_0_7 handle in every case, so a 4.0.7-born tenant never
planned the remaining chain and the bootstrap stall starved
mo_task.sys_cron_task into the nil-deref cascade
(pkg/bootstrap/custom_upgrade.go, service_upgrade_tenant.go: the
frozen 4.0_7 hop now commits OUTSIDE the planning transaction
through at most one on-demand pass, and the chain re-plans from the
advanced create_version; the v4_0_8 embed fixture expectation
follows); (B) the multi-cn PROXY fulltext 300s watchdog hang from
fencing-retirement witness rounds firing for commits that never
wrote staged state, compounding into lockservice starvation (new
D219 pre-round gate in RunDataBranchFencingRetirementCS: exclusive
ledger-row-key grant first, then locked-view committed-link and
row_kind=0 retention-identity probes; neither present skips the
witness round, watermark fold and certification entirely); (C) the
61->63 mo_catalog table-count diffs in the sp_table, show,
database_statistics, information_schema, create_user_default_role,
restore_cluster_table, cluster_level_snapshot_restore_cluster and
clone_sys_db_table_to_new_db_table .result oracles from the two new
catalog tables; and (D) the TestGCFiles round-two false PASS from
the D121 live-reference guard filtering a re-used fixed
object-name set (round 2 now writes fresh names whose
distinguishing byte lands inside the ObjectName.String() key
window the guard compares). The merge/pick
provenance aborts on the pess compose job are PR-caused but did NOT
reproduce in sustained local replays - both suites run 100% green
(2008/2008 merge, 1721/1721 pick) on a local two-CN
pessimistic-RC cluster under DISK-V2 and MINIO storage shapes; the
leading hypothesis is CI-runner evidence starvation from the class-B
retirement storm, whose gate is the direct remedy, and the post-push
CI run owns the verdict.

Close the PROXY-compose SIGSEGV class from run 40842554758: cn-1 died in
maphash.WriteString inside fifocache eviction (enqueueGhost/evict1/
deleteItem) hashing a 42-byte object-name cache key that pointed into freed
off-heap vector memory. The pk-move link spill ferry decodes block infos
with objectio.DecodeBlockInfo — an unsafe reinterpret over the ferried
batch's vector storage — and handed the aliasing blk.MetaLocation() into
LoadOneBlockWithSpecialLayout / ConstructObjStatsByLoadObjMeta; the meta
extent read then retained and re-hashed cache keys derived from memory its
owning batch had already released (49152-row spill groups, ~7.3MB objects,
~2KB meta extents — matching every crash key; fulltext.sql's big-index
build supplied the eviction pressure). Both producers now decode from or
copy into owned locations. Regression UTs assert every FilePath the
fileservice serves during read-back/repair stays disjoint from the
transient batch's vector storage (fails pre-fix, passes post-fix).
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 29, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).

CI repairs on the same head: DROP ACCOUNT now also retires the per-account
mo_data_branch_update_link and mo_data_branch_link_retention catalogs after
the tenant databases are gone, because every general tenant owns both tables
(new tenants via createSqls, existing tenants via the v4.0.8 upgrade), so
their mo_catalog.mo_tables rows outlived a dropped account and broke the
async-drop leftover accounting in TestDropAccountDuringAsyncIndexInit. The
synthetic pk-move link ctx now declares NotLockMeta: its cross-database
ObjRef otherwise flipped ordinary single-table UPDATEs from the sole
mo_tables name pin they retain on main into LockMeta.doLock's multi-database
branch (extra Shared mo_database pins on the user database and mo_catalog
plus a mo_tables pin on the link row), which let a competing DROP DATABASE
queue on the database pin before ever reaching the retained mo_tables pin
and broke the issue-29400 shared-gate choreography. zz_accesscontrol/
create_account and mo_cloud/mo_cloud BVT expectations list the two new
per-account catalog tables.
New focused regressions: TestUpdatePkMoveLinkCtxSkipsMetaNameLocks (plan),
TestDropAccountRetiresDataBranchCatalogs and
TestDropAccountDataBranchCatalogDropFailureAborts (frontend drop account).
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 29, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).

CI repairs on the same head: DROP ACCOUNT now also retires the per-account
mo_data_branch_update_link and mo_data_branch_link_retention catalogs after
the tenant databases are gone, because every general tenant owns both tables
(new tenants via createSqls, existing tenants via the v4.0.8 upgrade), so
their mo_catalog.mo_tables rows outlived a dropped account and broke the
async-drop leftover accounting in TestDropAccountDuringAsyncIndexInit. The
synthetic pk-move link ctx now declares NotLockMeta: its cross-database
ObjRef otherwise flipped ordinary single-table UPDATEs from the sole
mo_tables name pin they retain on main into LockMeta.doLock's multi-database
branch (extra Shared mo_database pins on the user database and mo_catalog
plus a mo_tables pin on the link row), which let a competing DROP DATABASE
queue on the database pin before ever reaching the retained mo_tables pin
and broke the issue-29400 shared-gate choreography. zz_accesscontrol/
create_account and mo_cloud/mo_cloud BVT expectations list the two new
per-account catalog tables.
New focused regressions: TestUpdatePkMoveLinkCtxSkipsMetaNameLocks (plan),
TestDropAccountRetiresDataBranchCatalogs and
TestDropAccountDataBranchCatalogDropFailureAborts (frontend drop account).
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 29, 2026
…T, and full generated-column expressions

Consolidates the catalog metadata corrections for matrixorigin#30936, matrixorigin#30935 and
upgrade ladder (matrixorigin#31497).

Defect corrections (unchanged in substance from the reviewed rounds):

- information_schema.COLUMNS binds the label-aware metadata helpers:
  ENUM/SET character/octet lengths follow the declared labels
  (multibyte included) and leave numeric metadata SQL NULL for
  ENUM/SET, keeping ordinary types byte-stable.
- STATISTICS.SUB_PART and SHOW INDEX Sub_part return the numeric
  prefix length from mo_indexes.algo_params (mo_index_sub_part) and
  actual SQL NULL for non-prefix indexes.
- information_schema.COLUMNS.GENERATION_EXPRESSION returns the full
  expression; the varchar(500) view cast is removed.
- Fresh publication (bootstrap init, CREATE ACCOUNT, subscriptions)
  serves the corrected identities unconditionally; historical
  snapshot readers keep recognizing their recorded definitions.

Delivery vehicle, per approved design revision 12
(docs/design/20261026-declared-catalog-metadata-publication-and-repair.md,
sha256 47ebfe15a45940221c3d2d5ad6955e11a5c89a1a909fa9d4e382e1ac9db0a599):

- pkg/bootstrap/versions/v4_0_8 is the successor hop of the frozen
  4.0.7 stage: two idempotent legs on the upstream shared builder
  (COLUMNS gate 109; prefix-aware STATISTICS gate 41), protocol
  floor 118, offset len(tenantUpgEntries), a plain per-entry
  HandleTenantUpgrade (no paging), no cluster entries; registered
  after v4_0_7.Handler. The revision-9 v4_0_18 carrier is deleted.
- The four 4.0.7-literal admission guards in checkUpgrade are re-keyed
  onto the consolidated-line comparison and the registered frozen
  handle's identity (D11-1/D11-2): legacy CDC admission at route
  creation, recheck and recovery; the ready frozen-source validation;
  the interrupted offset-only route rejection - upstream's message
  texts, error types and pre-mutation ordering are unchanged.
- The on-demand tenant walks continue past the paged 4.0.7 stage to
  the final version before caching completion (D12-1/D12-2):
  MaybeUpgradeTenant resumes the register walk in one bounded
  service-owned transaction after the stage commits, UpgradeOneTenant
  no longer terminates at the frozen branch for accounts already at
  4.0.7, and both walks keep mo_account.create_version as the sole
  progress marker: a failure leaves the cache unset and resumes from
  the committed stamp.
- Oracles: the admission suite (CDC admission/rejection at the
  successor registration including the recovery path and direct
  succession, frozen-source and offset-only rejections at both the
  pre-mutation check and recovery validation), and the continuation
  suite at the real v4_0_7 plus v4_0_8 registration (late-login
  convergence with second-login idempotence, manual chaining, manual
  upgrade from an already-stamped 4.0.7 account, successor failure/
  retry without premature caching, and the no-successor-SQL-before-
  stage-completion ordering), plus the re-derived route/hop tests on
  the consolidated ladder.

Rebase onto current main 1c80f16 (2026-10-30 round; the head was 30
commits behind and the merge state DIRTY):

- pkg/frontend/authenticate_test.go: upstream matrixorigin#31662 removed the CREATE
  ACCOUNT protocol ladder and its dedicated suite around our publication
  oracle; the retargeted
  TestCreateTablesInformationSchemaPublishesDeclaredMetadataUnconditionally
  now proves on the complete-current-set creation contract that the
  corrected declared-label COLUMNS identity and the prefix-aware
  STATISTICS identity publish and that no predecessor identity is ever
  authored. Consistent with upstream, account creation installs the
  complete current set or aborts.
- pkg/embed/catalog_view_identity_test.go: a caller-owned 4.0.6 tenant
  walk now ends at the registered 4.0.8 successor, so the final-version
  assertions move off the frozen 4.0.7 (the UT Test / UT Coverage /
  Coverage / CI Required failures of run 40792282505 failed exactly this
  assertion at the previous head).
- Upstream matrixorigin#31662's recurring columns/tables maintenance-scan removal and
  matrixorigin#31420's literal-prefix SHOW TABLES filter merge alongside this change
  without edits on this side beyond the conflict resolution above.
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 30, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).

CI repairs on the same head: DROP ACCOUNT now also retires the per-account
mo_data_branch_update_link and mo_data_branch_link_retention catalogs after
the tenant databases are gone, because every general tenant owns both tables
(new tenants via createSqls, existing tenants via the v4.0.8 upgrade), so
their mo_catalog.mo_tables rows outlived a dropped account and broke the
async-drop leftover accounting in TestDropAccountDuringAsyncIndexInit. The
synthetic pk-move link ctx now declares NotLockMeta: its cross-database
ObjRef otherwise flipped ordinary single-table UPDATEs from the sole
mo_tables name pin they retain on main into LockMeta.doLock's multi-database
branch (extra Shared mo_database pins on the user database and mo_catalog
plus a mo_tables pin on the link row), which let a competing DROP DATABASE
queue on the database pin before ever reaching the retained mo_tables pin
and broke the issue-29400 shared-gate choreography. zz_accesscontrol/
create_account and mo_cloud/mo_cloud BVT expectations list the two new
per-account catalog tables.
New focused regressions: TestUpdatePkMoveLinkCtxSkipsMetaNameLocks (plan),
TestDropAccountRetiresDataBranchCatalogs and
TestDropAccountDataBranchCatalogDropFailureAborts (frontend drop account).
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 30, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).

CI repairs on the same head: DROP ACCOUNT now also retires the per-account
mo_data_branch_update_link and mo_data_branch_link_retention catalogs after
the tenant databases are gone, because every general tenant owns both tables
(new tenants via createSqls, existing tenants via the v4.0.8 upgrade), so
their mo_catalog.mo_tables rows outlived a dropped account and broke the
async-drop leftover accounting in TestDropAccountDuringAsyncIndexInit. The
synthetic pk-move link ctx now declares NotLockMeta: its cross-database
ObjRef otherwise flipped ordinary single-table UPDATEs from the sole
mo_tables name pin they retain on main into LockMeta.doLock's multi-database
branch (extra Shared mo_database pins on the user database and mo_catalog
plus a mo_tables pin on the link row), which let a competing DROP DATABASE
queue on the database pin before ever reaching the retained mo_tables pin
and broke the issue-29400 shared-gate choreography. zz_accesscontrol/
create_account and mo_cloud/mo_cloud BVT expectations list the two new
per-account catalog tables.
New focused regressions: TestUpdatePkMoveLinkCtxSkipsMetaNameLocks (plan),
TestDropAccountRetiresDataBranchCatalogs and
TestDropAccountDataBranchCatalogDropFailureAborts (frontend drop account).
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 31, 2026
…RANCH apply

A branch-side primary-key change was emitted as an independent delete of the
old key plus an insert of the new key, so DATA BRANCH MERGE and DATA BRANCH
PICK replayed it as DELETE/INSERT: the parent-row delete failed with a
foreign-key constraint error whenever the destination declared ON UPDATE
CASCADE/RESTRICT actions, while an ordinary UPDATE on the same parent key
succeeded and cascaded to the child.

Record durable old-to-new update provenance for primary-key moves: the
multi_update producer registers a genesis-locked link into the
mo_data_branch_update_link catalog (keyed first-writer claim, genesis
presence probes bounded by the link_id primary-key prefix range), the change
stream re-associates the delete/insert pair through that link, and MERGE/PICK
apply the move as one native destination UPDATE so declared ON UPDATE actions
run. Provenance retention is owned by a certified funnel with
snapshot/PITR/account coverage rules, fail-atomic owner-removal reaping, and
genesis-lock conflict fencing; ambiguous or unresolved stream evidence aborts
the apply fail-closed instead of emitting unsafe DELETE semantics.

Related to matrixorigin#28026.

Rebased onto main 3cf3888 after matrixorigin#31497 consolidated the unpublished
4.0.8-4.0.17 catalog steps into the frozen 4.0.7 handler: the tenant-upgrade
package relocates to v4_0_8 (Version 4.0.8, MinUpgradeVersion 4.0.7) and
registers after v4_0_7; the frozen-4.0.7 gates in checkUpgrade now key on the
recorded cluster version and the registered frozen handler so a newer final
version keeps the offset-only, offset-mismatch, and legacy-CDC rejections; the
manual-upgrade no-replay coverage splits into behind-cluster rejection (4.0.7
account) and generic final-version no-replay (4.0.8 account);
TestPublishedCatalogUpgradeRoutes gains the 4.0.7 -> 4.0.8 hop including a
ready-4.0.7 fixture; lifecycle_branch_reclaim.go merges matrixorigin#31484's variadic
waitPolicy with the admission-time reclaim identity capture.
Also harden the watermark-fold error classification: awaitLedgerWatermark
maps any error observed at or after the one entry-minted absolute fold
deadline to the named fold-timeout class by wall clock, closing the window
where a stall-delayed inner wait error crossed the deadline before the
derived fold context's deadline flag became visible (observed live during a
host-wide scheduler stall as a 20710 lock-wait surface instead of the
fold-timeout class).

CI repairs on the same head: DROP ACCOUNT now also retires the per-account
mo_data_branch_update_link and mo_data_branch_link_retention catalogs after
the tenant databases are gone, because every general tenant owns both tables
(new tenants via createSqls, existing tenants via the v4.0.8 upgrade), so
their mo_catalog.mo_tables rows outlived a dropped account and broke the
async-drop leftover accounting in TestDropAccountDuringAsyncIndexInit. The
synthetic pk-move link ctx now declares NotLockMeta: its cross-database
ObjRef otherwise flipped ordinary single-table UPDATEs from the sole
mo_tables name pin they retain on main into LockMeta.doLock's multi-database
branch (extra Shared mo_database pins on the user database and mo_catalog
plus a mo_tables pin on the link row), which let a competing DROP DATABASE
queue on the database pin before ever reaching the retained mo_tables pin
and broke the issue-29400 shared-gate choreography. zz_accesscontrol/
create_account and mo_cloud/mo_cloud BVT expectations list the two new
per-account catalog tables.
New focused regressions: TestUpdatePkMoveLinkCtxSkipsMetaNameLocks (plan),
TestDropAccountRetiresDataBranchCatalogs and
TestDropAccountDataBranchCatalogDropFailureAborts (frontend drop account).

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

kind/bug Something isn't working kind/documentation Improvements or additions to documentation size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Consolidate catalog upgrade to 4.0.7 for 4.1 and 4.2

3 participants