Repository navigation
feat(hakeeper): implement catalog metadata capability barrier (#29004) - #29060
Conversation
XuPeng-SH
left a comment
There was a problem hiding this comment.
P2 blocker at pkg/hakeeper/catalog_metadata_schedule.go:78-93: an admitted StartReplica/StartNonVotingReplica command without a permit can survive membership removal and retirement. The cleanup predicate handles tokenless add/remove commands and permit-bearing start commands, but not this tokenless start command. Delivery then rejects the removed replica while the command remains pending; snapshot/restart reuse the same predicate. This can keep hasPendingHAKeeperAdmission true and block later persisted-expression activation. Please reclaim the command using the removed/retired replica identity and add real Update, heartbeat-delivery, and snapshot-recovery regression coverage. Current head and CI were verified at ab94e11.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
Deep first-principles review of the control-plane barrier implementation (RSM arbitration runtime, schedule prepare/obsolete/attach paths, snapshot codec floors, logservice executor state machine, CN/proxy participant observation, heartbeat plumbing, recovery and fencing logic). The implementation is internally consistent: the whole runtime is dormant without an internal tag-23 entry (no public producer exists, matching the documented deployment boundary), decoder-floor retention on rejected entries is deliberate and validated, snapshot feature gating (MOH3 + runtime feature bit) is coherent, staged-validate-then-commit in handleCatalogMetadataRequest keeps rejected entries atomic, the executor's durable latch/serialized STARTING/STARTED/REVOKING/REVOKED supervisor handles crash and redelivery correctly, lock ordering (catalogExecutor -> store mu) is consistent, and heartbeat-driven state transitions are deterministic within replicated entries. Test coverage is extensive, including unhappy paths, snapshot corruption, race scenarios, and the previously reported P1/P2 fixes. I independently re-verified the outstanding CHANGES_REQUESTED finding from XuPeng-SH at head ab94e11 and confirm it is valid and unaddressed: catalogScheduleObsolete (pkg/hakeeper/catalog_metadata_schedule.go:68) never reclaims tokenless StartReplica/StartNonVotingReplica commands, so after membership removal such a command is undeliverable (prepareCatalogSchedule cannot grant a permit for a removed/revoked member) yet remains pending forever, keeping hasPendingHAKeeperAdmission true and blocking persisted-expression/view-admission progress. The same predicate gap also covers tokenless StopReplica/KillZombie remnants for removed replicas (e.g. when prepareCatalogStop's REVOKE_START is rejected), so the fix should reclaim by removed/retired replica identity for all tokenless HAKeeper config-change command types, not only start commands. Per review policy this is not duplicated as a new finding; the PR should not merge until that existing requested change is resolved. No additional blocking or non-blocking findings from my review.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Astra medium deep review at exact head a34095a.
此前 P2 finding 已闭合:catalogScheduleObsolete 现在按 replica ID、UUID、role 和 revoked 状态回收 tokenless epoch-zero StartReplica/StartNonVotingReplica;membership removal 不再依赖被移除 store 的后续 heartbeat。StopReplica/StopNonVotingReplica/KillZombie 的 retirement/permit 语义也已闭合,真实 zombie 仍保留必要清理路径。
同一 obsolete predicate 已覆盖 UpdateCommands admission、catalog commit 后 prune、heartbeat delivery 前过滤和 snapshot recovery。新增回归覆盖真实 Update、heartbeat、RecoverFromSnapshot,验证残留清理与 hasPendingHAKeeperAdmission()==false,并保留 unfinished retirement 和 observed zombie controls。
已复查完整 diff 及 RSM arbitration、prepare/obsolete/attach、snapshot floor、executor/latch、CN/proxy heartbeat、recovery/fencing、锁顺序、失败/重放/清理和状态有界性,未发现新增 P0/P1/P2 缺陷。注意 hasPendingHAKeeperAdmission 只统计 add/start,不直接统计 stop/kill。
exact-head CI 已通过,race short matrix artifact 确认五个相关包实际执行且 status=0。维护切换及未来 producer 的端到端验证不在本次结论内。
APPROVE。
Merge Queue Status
This pull request spent 1 minute 31 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
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 2d7420cdfc, XuPeng-SH approval 5233521645. This replaces the initial partial-checkpoint description; the runtime implementation is now included.
Implementation
Deployment and ownership boundaries
CatalogMetadataMaintenancedefaults 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.MetadataReadsEnabledremains false. Catalog transactions/outbox producers belong to [Subtask]: Implement durable View metadata generations and recovery #29005; public authority/drain/retirement producers belong to [Subtask]: Validate and harden on-demand View metadata execution and plan reuse #29006. This PR implements their internal consumers and control contracts, not synthetic business completion.Validation
Initial runtime validation:
721ec91342, after mergingmo/mainat24e66eba12. See the review follow-up below for the current candidate. Darwin/arm64, Go 1.26.4, worktree-local native artifacts and that worktree'smo-cgo-testwrapper.pkg/hakeeper,pkg/pb/logservice,pkg/logservice,pkg/cnservice, andpkg/proxy.-vet=all -run '^$'checks: passed (the latter are vet-only evidence).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 —
ab51f14441Merged latest
mo/mainat780ef933f2and addressed both reported findings:fmt.Errorfwithmoerr.NewInvalidStateNoCtx, with an error-class assertion. The exact Linux/arm64 CI failure at run 35225175541/job 105214874658 was verified and reproduced locally (make err-checkexit 2); the correctedmake err-checkpasses. The previous golangci result did not cover this separate repository gate.New validation: HAKeeper/PB/LogService full normal tests with
-vet=alland 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:
UpdateCommandsnow 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;
KillZombieis 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.