Skip to content

[4.2] fix(cnservice): gate startup on self-visible cluster inventory - #27167

Merged
mergify[bot] merged 1 commit into
matrixorigin:4.2-devfrom
LeftHandCold:backport/4.2-cn-self-inventory-readiness
Aug 14, 2026
Merged

mergify[bot] merged 1 commit into
matrixorigin:4.2-devfrom
LeftHandCold:backport/4.2-cn-self-inventory-readiness

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #27152

What this PR does / why we need it:

Backports #27166 (f0d9a378ed) to 4.2-dev.

A replacement CN can publish a successful heartbeat and become visible to Proxy while its own local MOCluster still contains a pre-registration snapshot that does not include that CN. IVF entries scans require the current coordinator CN because only it can expose local appendable ranges, so this ordering gap can reject valid requests with required-current-cn-outside-pool.

This change gates CN startup before bootstrap and all query ingress until:

  1. the first CN heartbeat succeeds;
  2. an authoritative local cluster refresh succeeds; and
  3. the refreshed snapshot contains this CN's service ID, pipeline address, and build commit.

The retry is bounded by the existing HAKeeper discovery timeout. Failure uses the existing CN startup rollback path. The change does not relax tenant/label pool isolation or IVF's CurrentCNRequired rule, and it adds no query or transaction hot-path work.

The original regression tests are included unchanged.

Testing

  • go list -mod=readonly ./pkg/cnservice
  • go build -mod=readonly ./pkg/cnservice
  • go test -mod=readonly -count=1 -timeout=300s ./pkg/cnservice
  • each of the five new readiness/lifecycle tests under -race -count=100
  • go test -mod=readonly -race -count=1 -timeout=600s ./pkg/cnservice
  • go vet -mod=readonly ./pkg/cnservice

Wait for a successful CN heartbeat and an authoritative MOCluster refresh that contains the current CN generation before opening ingress. This prevents replacement CNs from serving IVF queries against a pre-registration local inventory.

Add deterministic startup ordering, stale generation, cancellation, refresh failure, and capability regression tests.
@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 →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep-reviewed exact head 12b383f2e03499163c077dc979c9a48f12e309d7. No blocking findings.

The startup invariant is closed end-to-end: a successful current CN heartbeat is committed by HAKeeper, a serialized authoritative refresh publishes a newer local snapshot, and the snapshot must contain the exact UUID/pipeline-address/commit generation before bootstrap or Query/SQL/pipeline ingress starts. This preserves the existing label/work-state/pool selection semantics rather than bypassing them.

I specifically revalidated the 4.2 lifecycle differences from main. Failure is fail-closed and reaches the existing startup rollback: the stopper terminates heartbeat/cluster tasks and the cluster/HAKeeper/RPC resources are closed. Heartbeat wait, refresh admission/RPC, and retry timers all have context deadlines; there is no new goroutine or unbounded accumulation.

Local validation:

  • pkg/cnservice/...: full tests passed
  • pkg/cnservice/...: full -race passed
  • 5 new readiness/lifecycle tests: -race -count=100 passed
  • clusterservice authoritative-refresh/cancel tests: -race -count=100 passed
  • go vet ./pkg/cnservice/... and git diff --check: passed

Required CI is green; the two cancelled connector jobs are unrelated optional workflows.

@mergify mergify Bot added the queued label Aug 14, 2026
@mergify

mergify Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-14 11:12 UTC · Rule: release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-08-14 11:13 UTC · at 12b383f2e03499163c077dc979c9a48f12e309d7 · squash

This pull request spent 16 seconds in the queue, including 2 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)

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 size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants