mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[GH-ISSUE #4522] [Bug]: HA promotion can lose its lease during large Oplog catch-up and repeat recovery #1153
Labels
No labels
ascend
auto-closed
bug
bug
CI/Build
Common
documentation
enhancement
feature request
good first issue
help wanted
high priority
MetaX
nightly-failure
pull-request
PyTorch Backend
question
RFC
Roadmap
stale
Store
Tests
Transfer Engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/Mooncake#1153
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Icedcoco on GitHub (Oct 9, 2026).
Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/4522
Bug Report
Summary
When a standby with a large Oplog backlog is promoted, Mooncake acquires the candidate leadership lease before completing Oplog catch-up, restore, and serving warmup. If recovery takes longer than the lease protection window, the candidate can lose leadership during warmup and return to the candidate/standby state. The already completed catch-up may then be discarded, causing the next attempt to replay the same history again.
This creates election churn and can leave the service unavailable for much longer than the time required for a single recovery attempt.
Observed behavior
During a controlled HA switch with snapshot creation disabled, repeated object cleanup had produced a large historical Oplog. The Oplog grew to approximately 255 MB, with a Raft index of about 95,443. The candidate followed this sequence:
Clients observed
Connection refusedwhile the node repeatedly cycled through candidate and leader-warmup states. The affected performance run could not be used as a valid result.The failure is not limited to a slow first attempt. In a later recovery observation, the standby applied sequence progressed as follows while targeting the same durable Oplog prefix:
The standby had nearly caught up with the durable prefix, then returned to an earlier recovery position after promotion or warmup failed. This indicates that completed catch-up progress was not retained for the next attempt.
Current recovery flow
The current supervisor flow is approximately:
master_view.TryAcquireLeadership().PreparePromotionLocked().leader_warmup, then restore state, register RPC, and run serving preflight.In other words, the candidate obtains leadership before it has confirmed that its applied sequence has reached the durable prefix. A large catch-up or restore can therefore outlive the lease's effective protection window. If warmup or keepalive fails, the candidate gives up leadership and the next attempt may restart from an older cursor.
Root cause
The leadership lease lifetime is not coordinated with the duration and progress of Oplog catch-up and restore. The recovery state also does not provide a monotonic handoff point that preserves completed catch-up work after a failed promotion attempt.
The current
IsReadyForPromotion()behavior permits promotion with a large lag and expects the remaining Oplog to be synchronized during promotion. That policy is unsafe when the candidate's fencing or leadership lease can expire before synchronization completes.This is not evidence that HA recovery is permanently impossible. It is a recovery-state and lease-management defect that is amplified by a large Oplog and a short lease protection window.
Expected behavior
master_viewmust remain explicitly non-routable until the node is ready to serve.Proposed validation
Add a regression test with:
The test should verify that:
service_ready=true, the publishedmaster_viewcontains the serving endpoint, and the applied sequence remains at or beyond the durable prefix without falling back;For performance and reliability tests, use an isolated Oplog namespace or compact/snapshot between cases. Otherwise, cleanup records from earlier cases can artificially inflate the recovery history and obscure the behavior being measured.
Acceptance criteria
The issue concerns the interaction between the HA leadership supervisor, standby promotion and restore, the etcd lease coordinator, Oplog catch-up, and recovery cursor persistence. It is separate from data corruption: the observed problem is repeated recovery and an extended unavailable window when promotion does not complete.
Before submitting...
@github-actions[bot] commented on GitHub (Oct 9, 2026):
Thanks for opening this issue, @Icedcoco!
102317026A maintainer will triage this when possible. To help us respond faster, please include:
Useful links: Documentation · Contributing guide