mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[GH-ISSUE #2971] [Bug]: ETCD OpLog is enabled implicitly for etcd HA but lacks retention and complete metadata replication #767
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#767
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 @no-teet-on on GitHub (Jul 17, 2026).
Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/2971
Originally assigned to: @Icedcoco on GitHub.
Bug Report
Description
Before the commit that introduced the MC_ENABLE_HA_METADATA_REPLICATION feature gate, selecting etcd as the HA backend automatically enabled OpLog following:
capabilities.has_oplog_following =
spec.type == HABackendType::ETCD;
As a result, every deployment using etcd for leader election also entered the etcd OpLog replication path, with no way to use etcd only for leadership coordination.
Current problems
Leader election is tightly coupled with metadata replication
Using ha_backend_type=etcd implicitly enables OpLog following. Users cannot independently enable etcd leader election while disabling the experimental metadata replication path.
OpLog entries do not have a TTL
Entries under the following prefix are written using regular etcd Put or BatchCreate operations without an attached lease:
/oplog/<cluster_id>/<sequence_id>
The following metadata keys also have no TTL:
/oplog/<cluster_id>/latest
/oplog/<cluster_id>/snapshot/<snapshot_id>/sequence_id
There is no automatic OpLog cleanup
EtcdOpLogStore::CleanupOpLogBefore() can delete entries below a sequence boundary, but it is not called by any production path. It is currently only exercised by tests.
Therefore, once production OpLog writes are enabled, the number of keys and the etcd database size can grow indefinitely.
The primary write path is not fully integrated
The production request path does not appear to:
Consequently, a standby may start an OpLog watcher even though the active primary is not publishing the required records.
Promotion does not hand replicated metadata to the serving master
HotStandbyService maintains an internal metadata store and provides ExportMetadataSnapshot(). However, the promotion path creates a new WrappedMasterService without transferring the replicated
standby metadata or its last applied sequence ID.
This means that successfully applying OpLog records in the standby does not necessarily make that state available to the newly promoted serving master.
Impact
Expected behavior
Leader election and metadata replication should be independently configurable.
Until the metadata replication path is complete, etcd OpLog following should be disabled by default and enabled only through an explicit feature gate such as:
MC_ENABLE_HA_METADATA_REPLICATION=1
The complete implementation should also:
Before submitting...
@github-actions[bot] commented on GitHub (Jul 17, 2026):
Thanks for opening this issue, @no-teet-on!
305664233A maintainer will triage this when possible. To help us respond faster, please include:
Useful links: Documentation · Contributing guide
@Icedcoco commented on GitHub (Jul 17, 2026):
Thanks for the detailed write-up. I checked this against the current
mainbranch, and the concerns in points 1 and 4 are valid. Leadership and metadata replication are still coupled: choosingha_backend_type=etcdalso enables OpLog following, without an independent option to turn replication off. At the same time, the primary write path is not fully wired while the standby reader can already be started. We’ll get these two issues fixed as soon as possible.For point 2, the lack of TTL is intentional. OpLog entries are durable recovery data, so expiring them through etcd leases could leave gaps in the replay history. They should instead be removed through an explicit retention policy once a durable snapshot covers the relevant sequence range.
Point 3 is also valid: automatic cleanup has not been implemented yet. The intended approach is to clean up old OpLog entries after a snapshot is safely persisted, while making sure lagging standbys can either continue replaying or bootstrap from a retained snapshot.
Point 5 is being addressed in #2826, which passes the replicated metadata, segment state, and last applied sequence ID into the promoted master. Please feel free to take a look and leave comments if you spot anything we missed.
@Colors-111 commented on GitHub (Aug 21, 2026):
I found the issue problem 1 still reproduces in the current codebase
f90ae691f109e49a60920e0c8abbf7e572826d8c: with only--enable_ha=true, Mooncake fails to start up normally — OpLog must also be enabled. Could you confirm whether this is by design? I think it would be better make--enable_hawork without requiring OpLog.@Icedcoco commented on GitHub (Aug 21, 2026):
Thanks for catching this. I confirmed that the failure is in the promotion path, not caused by OpLog enablement. When only
enable_ha=trueis set, the no-op standby controller cannot completePromoteStandbyAndExport(), so the elected leader never enters the serving state.This is not intended:
enable_hashould work independently without requiring OpLog. We will fix it immediately and add a regression test for the HA-only configuration.