Repository navigation
fix: wait for View metadata catalog upgrade before CN admission - #28020
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 re-review on exact head 85a04f940e471c9e0e53681f74d928b6de06072b. The previous deadline-owner, transient-retry, stale-epoch, and final handoff TOCTOU blockers are closed. The publication/handoff mutex gives a real linearization point, mixed rollback failures remain fail-closed, and retry state/backoff are bounded.
[P1][startup correctness] Do not accept catalog admission after the automatic upgrade has already failed.
Both success paths in waitForViewMetadataAdmissionHandoff return directly from acceptViewMetadataAdmissionSnapshot (lines 347-350 and 423-425) without first observing bootstrapUpgradeResult. The result channel is only read in the later error/select paths. Therefore an already-buffered terminal BootstrapUpgrade error is lost whenever the View catalog is usable and the admission snapshot is valid.
I reproduced this deterministically on this exact head with a review-only Start-level test: BootstrapUpgrade returns a sentinel error; the lifecycle-gate executor waits until len(bootstrapUpgradeResult)==1, then returns a valid gate row. The upgrade failure is logged, but Start() returns nil and ingress becomes ready. It fails 20/20. This is reachable if the View catalog transaction committed and a later automatic-upgrade step failed, or if the catalog was already present while upgrade failed elsewhere.
Please make every successful admission/handoff transition reject an already-completed upgrade error (without unnecessarily turning the intentionally asynchronous successful upgrade into a synchronous startup dependency), and add this ordering as a deterministic regression. The existing failure test only keeps the catalog fence incomplete, so it necessarily reaches the select and misses this path.
No additional blocking lock-order, cancellation, retry-growth, catalog-presence, or performance issue was found. Exact-head CI is green; the review-only test was removed with its temporary worktree.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep re-review completed on exact head 0fb86760f8c49c3ed56734b0ad53d86a0d570858 against merge base 9f711e21346ff52aa082ccf86999c4cfb4f84943. I read every changed hunk and traced the complete BootstrapUpgrade owner -> catalog fence/retry -> authoritative snapshot publication -> final ingress handoff -> shutdown closure, including the delta since my prior CHANGES_REQUESTED review.
The previous P1 is closed. Terminal upgrade-result publication and admission acceptance now share the same linearization lock, and both the disabled and admitted success paths poll an already-published terminal error before acceptance. The deterministic Start-level regression proves that a failure buffered after the catalog becomes usable is returned instead of publishing ingress readiness; a still-running successful upgrade remains asynchronous.
No additional blocker was found:
- correctness: partial-catalog states remain fail-closed, joined rollback failures are not retried, stale epochs/generations cannot open ingress, and the final listener handoff is linearized with heartbeat publication;
- liveness/resources: the upgrade task, timer, and channels have terminal owners; stopper cancellation and the 120-minute owner context terminate waits; retries retain constant state;
- performance/operations: heartbeat publication adds only a short constant-time mutex section, catalog retries use capped per-CN jittered backoff (max below 5s), and same-epoch heartbeats cannot bypass it. This reduces rather than amplifies the previous retry/log pressure.
Evidence: exact-head substantive CI is green, including Linux UT/SCA and standalone/compose BVT; author-provided exact-head focused normal/race and owning-package runs are semantically applicable; git diff --check passes. The isolated macOS worktree correctly refused to reuse a mismatched cgo/libmo.dylib, so that local prerequisite failure was not counted as test evidence. Current main has advanced only through unrelated clone files, so the reviewed dependency closure is unchanged.
What type of PR is this?
Which issue(s) this PR fixes:
issue #27967
What this PR does / why we need it:
PR #27976 prevented internal catalog DDL from entering the generic View metadata lifecycle hooks, but CN startup could still race the asynchronous v4.0.6 same-version offset upgrade. Admission attempted to fence the lifecycle catalog before
mo_view_dependenciesandmo_view_refreshwere committed, then startup teardown canceled the upgrade owner and repeated the same failure on restart.This PR keeps CN ingress closed while that catalog closure is unavailable:
mo_view_refreshlifecycle gate row exists before writing the revalidation marker, so neither/only-dependencies/only-refresh states remain unadmitted;errors.Joinrollback wrappers while mixed rollback failures remain fail-closed;BootstrapUpgradeerror instead of masking it behind HAKeeper discovery timeout;ErrTxnNeedRetry, andErrTxnNeedRetryWithDefChangedonly while that upgrade owner remains live;Startteardown;BootstrapUpgradefailure wins over both catalog-ready success paths without waiting for a still-running successful upgrade;The main-to-4.2 HAKeeper rollback remains unsupported and is not changed by this forward-upgrade fix.
Validation on
0fb86760f8after mergingmo/main @ 9f711e2134:-count=50: PASS;-count=30: PASS;.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m ./pkg/sql/compile: PASS;.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m ./pkg/cnservice: PASS;.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=20m ./pkg/cnservice: PASS;.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=20m ./pkg/tests/upgrade: PASS;go vet -mod=readonly ./pkg/sql/compile ./pkg/cnservice ./pkg/tests/upgrade: PASS;Startis 77.5%.