Repository navigation
fix(cnservice): preserve bootstrap ownership through admission handoff - #29450
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of 9ea665b7a0a24785b770e3858bfdd1185d38a21d against merge-base d99187d7b3bfda8744088b3ae8cf16739b690aa0. APPROVE: no blocking findings in this change. Reviewed directly; no subagents.
Design and correctness
The fix addresses a real ownership gap: committing the catalog fence does not complete startup admission. HAKeeper can still legitimately be draining the previous generation. Falling back to the shorter discovery deadline at that point abandons a still-active bootstrap operation.
Keeping the existing bootstrap owner responsible until the final handoff is coherent. This is an ordinary corrective change, not a new state machine requiring a separate feature design. It adds no protocol/configuration, alternate admission path, or timeout increase. The 120-minute owner bound already exists; absent authority/no active owner retain the discovery bound.
I traced Start -> bootstrap context/result publication -> local admission/system-view initialization -> final ingress acceptance -> startup-ready notification, plus heartbeat/HAKeeper replacement-generation handling. Successful bootstrap result publication waits for startup-ready, so normal owner completion cannot prematurely remove ownership between these startup phases. Old-generation draining, epoch fencing and persisted-expression protocol checks remain in force.
Cancellation is checked both at loop entry and under the admission mutex before acceptance. An already-buffered concrete failure takes precedence over cancellation. Error rollback still belongs to Start/closeService; stopper cancellation, result-channel capacity, epoch-fence close, scoped catalog transaction timeout and retry-timer cleanup remain bounded. No new goroutine, unbounded queue, retry fan-out or background resource owner is introduced.
Independent QA and evidence
Locally on Darwin/arm64, Go 1.26.4, with verified matching native inputs:
- Eight focused tests passed under race detection: the three new regression groups, final-ingress linearization, both real Start bootstrap-error tests, system-views-before-ingress, and an independent reviewer probe.
- Each of the three new regression groups separately passed
-race -count=100:TestCNViewMetadataAdmissionOwnerAfterCatalogCommit,TestCNViewMetadataAdmissionDiscoveryRemainsBounded, andTestCNViewMetadataAdmissionCancelledOwnerCannotPublishIngress. - Independent
TestReviewerAdmissionOwnerAtLockedAcceptanceseparately passed-race -count=100. It queues acceptance behind the admission mutex, cancels the owner while acceptance is blocked, then releases the mutex. Oracle: no ingress publication and cancellation returned; with a buffered concrete upgrade failure, that error wins. The otherwise-identical live-owner control accepts. This tests a later cancellation boundary than cancel-before-entry. The probe is review-only, not a production/PR modification.
Exact-head CI run 36411062934 passed. I checked the UT checkpoint artifact: the successful light race stage explicitly selects cnservice and HAKeeper, rather than inferring package coverage from the rollup alone. Reused the author's reported Linux package/upgrade evidence after verifying the reported final validation tree matches this head's tree 112c154d7351b38789282aa7203d9479186f7d63; those upgrade experiments were not independently rerun here.
Performance, engineering and limits
Production changes are small (+27/-11): startup-only context/result checks, with no SQL execution hot-path change. Existing retry backoff and notification coalescing are retained. Longer startup during legitimate generation draining is the intended correctness behavior, not a claimed query-performance improvement. The new lightweight synctest cases cover distinct ownership/timeout/generation boundaries without introducing an embedded-cluster fixture.
There were no previous human reviews or inline review comments to resolve; the only existing PR comment is the review-bot subscription notice.
Approval is for this bounded admission-handoff fix, not proof that every interrupted-upgrade history is recoverable. Upgrade CI jobs were skipped, not passed. Original issue #29396's retained QA data and actual multi-CN interrupted-upgrade recovery remain unverified. The author also explicitly reports that an already-in-progress upgrade targeting 4.0.9 cannot simply be resumed by a 4.0.10-target binary due to the existing framework guard; this patch does not change that contract. Preserve these limits when declaring the original incident fully resolved.
Merge Queue Status
This pull request spent 28 seconds in the queue, with no time running CI. ReasonPull request #29450 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.
HintYou 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. Tick the box to put this pull request back in the merge queue (same as
|
Complete the S1 implementation-gating design against the current on-demand implementation already merged in #29139, rather than rebuilding the superseded durable-refresh architecture. - Map 17 consumer boundaries and classify all current `Type`, `ColDef`, and `mo_columns` fields as authoritative definition state, derived output, or physical compatibility data. Include the `SELECT * FROM view LIMIT 0` catalog shortcut, column-count SHOW, prepared/cached/cursor paths, subscriptions, and the actual unsupported boundaries of COM_FIELD_LIST and View DUMP TABLE. - Specify one read-only inference/provenance contract, statement-local ownership and memoization, snapshot/own-DDL behavior, frozen stars, legacy definitions, authorization, invalid-view errors, and historical system-template adaptation. - Make the raw-catalog choice explicit: direct `mo_columns` reads retain physical/MVCC compatibility semantics and are not a current View-schema interface. Record the required reconciliation with #26227's earlier persistence-oriented acceptance criteria. - Define numeric resource/performance budgets, benchmark cases, mixed-version activation and rollback restrictions, and the shared admission/protocol/snapshot protections that must survive refresh retirement. - Map remaining work and evidence to S2–S9; cross-request caching remains conditional and separately reviewed. No older issue is edited or closed by this change. ### Exact design revision and approval - Commit: `371e3c1761dab22dff95d0e830caab31aa46eeeb`. - [Reviewed design: v2.0-draft.1](https://github.com/ck89119/matrixone/blob/371e3c1761dab22dff95d0e830caab31aa46eeeb/docs/design/CLAUDE_20260922-view-metadata-on-demand.md). - Design SHA-256: `f8cd0a71d59c37d14bb6dc964e968d4c68b0d95b01cb6a371f597c1eb6ea0120`. - [Approval and self-review record](https://github.com/ck89119/matrixone/blob/371e3c1761dab22dff95d0e830caab31aa46eeeb/docs/design/CLAUDE_20260928-view-metadata-s1-review.md). The requester approved this exact revision after the design and the four material choices (raw-catalog compatibility, legacy rejection, rollback restrictions, and numeric budgets) were presented. The approved design bytes are frozen; its pre-approval wording is intentionally retained, with the subsequent APPROVED status recorded separately. This is a task-session approval record, not a claimed GitHub review vote or production rollout approval. ### Validation and delivery scope - Documentation only: two Markdown files; no production, test, generated-code, or configuration changes. - `git diff --check` and staged-diff checks passed. - Lightweight document checks passed: 35 local file links, 21 consistent Markdown tables, balanced code fences, numbered sections, 17 consumer entries, and 10 decisions. - Field-inventory checks cover 9 `Type`, 22 `ColDef`, and 27 `mo_columns` fields; the approved design checksum matches the approval record. - Updated the branch to `mo/main` at `3fe37b311df718eb7b369513cd6d615b10b04092` and reviewed the complete #29450 increment. Its bootstrap-owner/admission fix preserves the shared protections required by this design; no design-contract change was needed. - Go tests, BVT, race, mixed-binary/restore tests, and benchmarks were not run for this documentation-only change. Their required evidence remains assigned to the implementation phases; historical #29139 results are not relabeled as fresh validation. Approved by: @XuPeng-SH
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29396
What this PR does / why we need it:
After an interrupted upgrade, repairing the view metadata catalog does not necessarily complete CN admission. HAKeeper may still be draining the previous generation. The CN previously switched back to the shorter discovery deadline as soon as catalog fencing succeeded, even though its bootstrap owner was still waiting for the startup handoff. This could abort recovery after the catalog upgrade had completed, before SQL became ready.
This change:
The new lightweight
testing/synctestregressions cover catalog commit followed by delayed admission, preparing/enabled epochs, initialization/ingress/derived-definition callers, owner failure/cancellation/deadline/completion, superseded generations, and bounded discovery. They use virtual time and quiescence barriers rather than real-time sleeps to win scheduling races.Validation
The delivered patch is the same two-file change validated on main
239fe81c82ae07a8c316576cac8555c445c92212, using Go 1.26.4 and matching Linux/arm64 native artifacts:pkg/cnservice: whole-package normal/coverage and race runs passed through.agents/skills/mo-dev/scripts/mo-cgo-test(GOMEMLIMIT=offfor the existing memory-limit test's initial-state assumption).-race -count=100each, selected using measured durations; no repeated whole-package stress.TestViewMetadataAdmissionReplacementKeepsOldGenerationUntilTimeout,TestViewMetadataAdmissionCleanRestartSkipsOldGenerationTimeout, andTestViewMetadataAdmissionPreparingWaitsForReplacedGenerationTimeout.Actual interrupted-upgrade validation
Old binary: 4.2-dev
1a44f3db3056e32975fde86ca0ab69a094996a3f.Main baseline:
239fe81c82ae07a8c316576cac8555c445c92212(final catalog4.0.9 / offset 1 / state 2).The old binary naturally created a 4.0.6/offset-5 catalog, a user table with two sentinel rows, and a view. GDB killed the actual single LOG/TN/CN launch process at the v4.0.8 cluster-upgrade entry, before its repair DDL. No upgrade records were manually seeded. Each recovery run started from a separate copy of the same never-recovered interrupted data.
The 45s value is a valid test-instance HAKeeper configuration, identical for both binaries, not a product-default change or an increased CN discovery timeout. The baseline also failed under a diagnostic GDB run: its local and authoritative catalog-fenced epochs were already 1, while generation 101 was still preparing and not admitted after capturing the previous ready generation 1.
Passing scenarios checked MySQL readiness, both catalog tables, the user table/view rows, completed non-duplicate upgrade steps, and stable catalog table IDs across the next restart. The patched binary SHA256 is
62bb3df8c2d171b1704e7aa807334d91d4137220bc1e576a816310fadb4fd6da.Validation after merging the latest target branch
The PR branch now merges
mo/mainatd99187d7b3bfda8744088b3ae8cf16739b690aa0(remote merge commit9ea665b7a0a24785b770e3858bfdd1185d38a21d). Validation used an independently produced local merge commit19f7ace0de7a9366da96aa2a3e2c3ff0c66a246d; both commits have the exact same Git tree112c154d7351b38789282aa7203d9479186f7d63(no source/config/test difference). The current binary, built with Go 1.26.4 on Linux/arm64, has SHA256996c8e3b18ff5b42ed960f1287115db010d8a80886c9697d0553d78d947bdd4c. The target catalog is now4.0.10 / offset 1 / state 2, including protocol 100 and the new system-view upgrade.pkg/cnservicepackage passed normal/coverage (66.3%) and race runs via the repository CGo wrapper,-count=1in both modes.GOMEMLIMIT=offpreserves the initial-state assumption of an existing memory-limit test.mo_view_*catalog tables, stable IDs over restart, the two original user table/view rows, final catalog state, and exactly four complete, nonduplicate upgrade steps through 4.0.10. The 45s runtime reportsCNStoreTimeout=45000000000in its log; product defaults are unchanged.Separate failure boundary: Reusing the older checkpoint generated while the previous main was targeting 4.0.9 does not pass when upgraded directly to 4.0.10: the framework intentionally rejects a different version still marked
upgrading(cannot upgrade to version 4.0.10, because version 4.0.9 is in upgrading). We retained that failing evidence and did not bypass the guard or claim support for cross-target interrupted upgrades. The passing interruption above was performed by the current merged binary itself. Original QA data and multi-CN topology remain untested; no CI result is claimed.