Skip to content

[WIP] HAKeeper catalog metadata capability barrier (#29004) - #29049

Merged
mergify[bot] merged 5 commits into
matrixorigin:mainfrom
ck89119:issue-29004-main
Sep 17, 2026
Merged

mergify[bot] merged 5 commits into
matrixorigin:mainfrom
ck89119:issue-29004-main

Conversation

@ck89119

@ck89119 ck89119 commented Sep 17, 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:

Related to #29004; parent #26227. This checkpoint does not close either issue.

What this PR does / why we need it:

This is the single draft delivery PR for #29004. Per the requested workflow, design updates and subsequent implementation will remain in this PR; there will be no separate documentation PR.

Current checkpoint is design-first only. No production implementation is delivered yet. Do not merge as completion of #29004.

Adds docs/design/CLAUDE_20260917-catalog-barrier-rsm.md with independent participant acknowledgments, durable targets, transition evidence ownership, and explicit compatibility changes to the previously approved #29008 design.

The code trace identifies a concrete membership race: ordinary AddReplica commands leave the HAKeeper pending queue on delivery, before the executor calls Dragonboat. A barrier application entry does not advance the membership config-change index, so OrderedConfigChange alone does not fence a delayed add.

Design blockers are explicit rather than treated as implementation details:

  • Shared replicated arbitration of first barrier submission and actual membership admission, including commands delivered before upgrade.
  • Durable decoder floor even when a valid new entry's business transition is rejected; proposed MOH3 required-feature bit 2.
  • Runtime target evidence compatibility and catalog/public-authority owner boundaries across the subtask series.

The existing design approval does not cover these additions. Please review this checkpoint before implementation delivery. Runtime activation and MetadataReadsEnabled remain unchanged/disabled.

Validation: source-level execution-chain inspection and git diff --cached --check. No production code or generated protobuf changed; no UT/race success is claimed for this checkpoint.

@ck89119
ck89119 requested a review from XuPeng-SH September 17, 2026 07:30
@mergify mergify Bot added the kind/documentation Improvements or additions to documentation label Sep 17, 2026
@matrix-meow matrix-meow added the size/XS Denotes a PR that changes [1, 9] lines label Sep 17, 2026
@ck89119
ck89119 marked this pull request as ready for review September 17, 2026 08:01
@ck89119
ck89119 requested a review from fengttt as a code owner September 17, 2026 08:01
@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.

Astra medium deep review at exact head .\n\nREQUEST_CHANGES — this is a useful design checkpoint, but the design gate is not yet closed.\n\nP1 — Membership arbitration lacks a complete upgrade/recovery protocol (docs/design/CLAUDE_20260917-catalog-barrier-rsm.md:108-112). The delayed-add case can leave an already in-flight legacy command outside the new reservation coverage: HAKeeper removes delivered commands from pending state (pkg/hakeeper/rsm.go:815-832), while LogService executes with the original epoch (pkg/logservice/service_commands.go:74-90). Please specify the shared linearization point, legacy-command fencing, and reservation reconciliation after executor failure/timeout/leader change.\n\nP1 — Catalog evidence and authority retirement are undefined across owners (design lines 99-102). Define how CatalogRequired/RecoveryStarted/Complete evidence reaches the RSM, binds to the current claim/generation, rejects stale evidence, and how the lease issuer proves old-owner retirement/backpressure. Otherwise implementation must invent the safety conditions or can permanently block.\n\nP2 — The snapshot feature/state acceptance matrix is incomplete (design lines 114-118). Specify valid/invalid combinations of decoder floor, phase, target evidence, and feature bits, including malformed/unknown-version entries, legacy target-less snapshots, and rejected Begin replay semantics. Existing decoding requires exact feature/payload agreement and rejects unknown bits (pkg/hakeeper/snapshot_codec.go:80-98).\n\nNo P0 found. No runtime code/tests changed; CI passed documentation checks, while runtime/UT/upgrade jobs were skipped.

@XuPeng-SH

Copy link
Copy Markdown
Contributor

Clarification: the review above is pinned to exact head d6ac371 (PR #29049).

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

Astra medium deep review at exact head 30da8e2.\n\nREQUEST_CHANGES.\n\nP1 — Successful StartReplica cannot satisfy the reservation completion rule (docs/design/CLAUDE_20260917-catalog-barrier-review-resolution.md:32-45). The design reserves both add and start but releases only after the config-change index advances. Starting an already-admitted member via Dragonboat StartReplica does not change membership/config index (pkg/logservice/service_commands.go:103-110; pkg/logservice/store.go:524-533). Thus reserve-start -> successful start -> unchanged index can retain the reservation indefinitely, blocking later membership changes and the first Begin. Define separate completion/fencing semantics for local start versus Raft membership mutation, and test successful start with unchanged index followed by a new admission.\n\nP2 — BarrierSubmissionFence has no complete terminal/recovery contract (resolution document:28-31). Define fence identity, successor takeover, successful consumption, and safe release after proposer death between fence commit and Begin, while rejecting delayed proposals from the old owner. Add crash/snapshot/retry tests.\n\nP2 — Durable evidence retention has no reclamation/capacity contract (resolution document:60-72,111). Define cleanup handshake, superseded-evidence disposition, retention boundary, and bounded deduplication/backlog admission; otherwise repeated generations leave durable growth unspecified.\n\nNo P0 found. Snapshot/replay compatibility concerns from the previous review appear addressed. Exact-head CI passed documentation checks, but runtime/UT/upgrade/BVT jobs were skipped; no runtime tests were run locally.

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

Astra medium deep review at exact head 2d7420c.\n\nAPPROVE for this design-only change. The PR-specific diff contains two design documents; the previously identified reservation completion, submission-fence recovery, evidence reclamation, and snapshot/replay gaps are addressed by the new contract (with the documented maintenance/manual-retirement assumptions). No P0/P1/P2 finding attributable to this PR.\n\nThe review also checked the intervening merged files. A P2 allocation/preflight mismatch exists in inherited percentile code (pkg/sql/colexec/aggexec/aggState.go and capacity_preflight.go), but it is outside this PR diff and is not introduced by this change.\n\nExact-head CI passed documentation checks. Runtime/UT/upgrade/BVT jobs were skipped, which limits implementation validation but is appropriate for the documentation-only delta.

@mergify mergify Bot added the queued label Sep 17, 2026
@mergify

mergify Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-17 09:12 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-09-17 09:13 UTC · at 4c31142f4dbd0c46e9674b365826acc015b35ac2 · squash

This pull request spent 15 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify
mergify Bot merged commit 4c31142 into matrixorigin:main Sep 17, 2026
19 of 20 checks passed
@mergify mergify Bot removed the queued label Sep 17, 2026
@ck89119
ck89119 deleted the issue-29004-main branch September 17, 2026 09:14
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
… (matrixorigin#29049)

This is the single draft delivery PR for matrixorigin#29004. Per the requested workflow, design updates and subsequent implementation will remain in this PR; there will be no separate documentation PR.

**Current checkpoint is design-first only. No production implementation is delivered yet. Do not merge as completion of matrixorigin#29004.**

Adds `docs/design/CLAUDE_20260917-catalog-barrier-rsm.md` with independent participant acknowledgments, durable targets, transition evidence ownership, and explicit compatibility changes to the previously approved matrixorigin#29008 design.

The code trace identifies a concrete membership race: ordinary AddReplica commands leave the HAKeeper pending queue on delivery, before the executor calls Dragonboat. A barrier application entry does not advance the membership config-change index, so OrderedConfigChange alone does not fence a delayed add.

Design blockers are explicit rather than treated as implementation details:
- Shared replicated arbitration of first barrier submission and actual membership admission, including commands delivered before upgrade.
- Durable decoder floor even when a valid new entry's business transition is rejected; proposed MOH3 required-feature bit 2.
- Runtime target evidence compatibility and catalog/public-authority owner boundaries across the subtask series.

The existing design approval does not cover these additions. Please review this checkpoint before implementation delivery. Runtime activation and MetadataReadsEnabled remain unchanged/disabled.

Validation: source-level execution-chain inspection and `git diff --cached --check`. No production code or generated protobuf changed; no UT/race success is claimed for this checkpoint.

Approved by: @XuPeng-SH
XuPeng-SH pushed a commit that referenced this pull request Sep 19, 2026
#29060)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Fixes #29004. Parent: #26227.

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

Completes the #29004 control-plane implementation following merged
design PR #29049: [approved revision
2d7420c](2d7420c),
[XuPeng-SH approval
5233521645](#29049 (review)).
This replaces the initial partial-checkpoint description; the runtime
implementation is now included.

### Implementation

- **Independent decoder obligation:** update tag 23 retains floor 1 even
for rejected/malformed requests. RSM field 46 and MOH3 feature bit 2
remain independent of business phase and the existing
persisted-expression floor. Recovery validates feature/state agreement
and durable evidence before publishing any state.
- **Replicated membership arbitration:** allocator CAS; fence
acquire/takeover/release/atomic consume; durable reservations; complete
voting/non-voting membership and advanced config-index reconciliation.
Incarnation revocation is sticky; timeout is not completion evidence.
- **Durable local execution:** maintenance latch, serialized
STARTING/STARTED/REVOKING/REVOKED supervisor, independent start permits,
cancellation/redelivery, and restart recovery. Retirement can stop a
failed restart without first completing it. HAKeeper replicas recover
before data-shard zombie checks; retired permits and obsolete restart
metadata are reclaimed.
- **Six-phase barrier:** independent E/R/C, exact target-generation
acknowledgements, fixed receipt slots and recovery-claim fencing.
Supersession captures new participants without discarding unretired
owners. Explicit trusted retirement proofs unblock replaced/deleted
owners; pre-activation seal evidence does not retire authority issued
after ACTIVATED.
- **CN/Proxy participation:** generation-addressed monotonic
observations, independent acknowledgements, and the legacy
persisted-expression scalar mirror. Generic heartbeat observation cannot
manufacture seal/retirement completion or bypass existing decoder-floor
withdrawal.

### Deployment and ownership boundaries

- `CatalogMetadataMaintenance` defaults to false. First protocol entry
requires the approved controlled maintenance cutover: stop legacy
executors/HAKeeper processes, prevent old restart, restore admitted
replicas with supporting binaries, and discard no-token legacy
schedules. This is **not** zero-downtime mixed-version activation.
- There is no automatic Begin or public SQL activation API. CN/Proxy
advertise observation support, **not** ViewDependency/Recovery support;
LogStore advertises barrier support only behind the maintenance gate.
- **View lifecycle remains runtime-disabled; `MetadataReadsEnabled`
remains false.** Catalog transactions/outbox producers belong to #29005;
public authority/drain/retirement producers belong to #29006. This PR
implements their internal consumers and control contracts, not synthetic
business completion.

### Validation

Initial runtime validation: `721ec91342`, after merging `mo/main` at
`24e66eba12`. See the review follow-up below for the current candidate.
Darwin/arm64, Go 1.26.4, worktree-local native artifacts and that
worktree's `mo-cgo-test` wrapper.

- Full normal tests with coverage: **passed** for `pkg/hakeeper`,
`pkg/pb/logservice`, `pkg/logservice`, `pkg/cnservice`, and `pkg/proxy`.
- Catalog/snapshot race tests across all five packages: **passed**.
- Race ×100: atomic participant observations, serialized start/cancel,
retirement overtaking failed restart, and late-participant/retirement
progress: **passed**.
- Full race tests for all five owning packages: **passed**; final
`-vet=all -run '^$'` checks: **passed** (the latter are vet-only
evidence).
- Changed coverage blocks, statement-weighted and excluding
generated/test code: **981/1117 = 87.82%**. New implementation files
range from **80.93% to 100%**; evidence validator and participant helper
are 100%.
- Incremental golangci-lint 2.6.2: **0 issues**. The preinstalled
analyzer was built with Go 1.27.1; package loading/compiler/tests/gofmt
use Go 1.26.4.
- License check: **0 invalid**. Independent protobuf regeneration is
byte-identical; formatting and diff checks pass.
- Independent implementation review found three concrete defects;
regression tests and fixes were added, and the scoped follow-up review
is **PASS**.

Coverage includes real Update/RecoverFromSnapshot failure atomicity,
mixed capabilities, rejected-entry floors, stale owner/claim/receipt
evidence, complete configuration matching, lost delivery, contradictory
retirement acknowledgements, same-UUID replacement, explicit retirement,
and real Dragonboat start/stop/restart boundaries.

Earlier selector misses, tool timeouts, sandbox restrictions, and
disk-capacity failures are not counted as passing tests. No SQL BVT or
CI-success claim is made.

### Review follow-up — `ab51f14441`

Merged latest `mo/main` at `780ef933f2` and addressed both reported
findings:

- **P1:** persist the confirmed membership config-change index
atomically with completion. Reservations and replica readiness reject
heartbeat configurations below this high-water mark; snapshot recovery
preserves it and rejects contradictory reservations. Regression tests
fail before the fix and pass after it, covering consecutive operations,
delayed heartbeats, recovery, eventual successful completion, and fence
progress.
- **P2:** replace `fmt.Errorf` with `moerr.NewInvalidStateNoCtx`, with
an error-class assertion. The exact Linux/arm64 CI failure at run
35225175541/job 105214874658 was verified and reproduced locally (`make
err-check` exit 2); the corrected `make err-check` passes. The previous
golangci result did not cover this separate repository gate.

New validation: HAKeeper/PB/LogService full normal tests with `-vet=all`
and coverage; targeted race ×20 including the real executor lifecycle;
molint for the affected three packages; incremental golangci for all
five PR packages. All passed. Both pinned analyzers were rebuilt with
**Go 1.26.4**, matching CI. Changed-block coverage in the three retested
packages is **969/1104 = 87.77%** (not a new five-package measurement).
Independent protobuf regeneration remains byte-identical. The additional
full-tree license rerun timed out locally; the only new file's header is
byte-identical to the previously validated runtime header, and no new
license-run success is claimed.

### Review follow-up — tokenless stale schedules

A second tokenless membership command at the same epoch could remain
pending forever after the first command advanced the confirmed
configuration. The RSM now reclaims only tokenless HAKeeper membership
commands whose epoch is **strictly below** `ConfirmedConfigChangeIndex`,
both when successful replicated state makes them obsolete and when
recovering snapshots written by the buggy version. Commands with a live
token still use reservation identity; commands at the confirmed or a
future epoch remain pending.

The deterministic regression uses the real queue, heartbeat delivery,
Update completion, `hasPendingHAKeeperAdmission`, and
RecoverFromSnapshot paths. It proves cleanup after completion, migration
of inherited stale snapshots, and retention controls for equal/future
epochs.

A follow-up closed the remaining admission edge: `UpdateCommands` now
applies the same terminal-obsolescence predicate before queue lookup,
deduplication, ID allocation, or append. The regression submits a late
stale command through real Update after completion and immediately
proves an empty queue and unblocked admission—without heartbeat, another
catalog operation, or restart. The inherited-snapshot case now
constructs legacy residue directly rather than using the fixed admission
path.

The final review follow-up covers epoch-zero execution commands.
Tokenless start commands survive only for the exact admitted,
non-revoked identity and role. Tokenless stop/kill commands survive only
for an exact active member, an unfinished retirement permit, or a
locally observed pre-cutover zombie; `KillZombie` is rejected for
admitted members. Removed/retired or role-mismatched identities are
reclaimed at Update, completion, and snapshot recovery boundaries.
Regression coverage uses real Update, heartbeat delivery, and
RecoverFromSnapshot, with positive controls for an unfinished retirement
stop and an observed legacy zombie. HAKeeper full normal+vet passed at
86.2% package coverage; focused race ×50 and Go1.26.4 incremental lint
passed.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
ci — 2d7420cd Deployed Sep 17, 2026 by ck89119 via Matrixone Utils CI / pr-size-label #54560
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/documentation Improvements or additions to documentation size/XS Denotes a PR that changes [1, 9] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants