mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[GH-ISSUE #2910] [RFC]: Multi-Replica Reliability in Mooncake Store Data Plane #756
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#756
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 @liangxu2000 on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/2910
Changes proposed
Background
Mooncake Store ensures data reliability through a Multi-Replica mechanism:
replica_numcontrols the number of Memory replicas andnof_replica_numcontrols the number of NoF SSD replicas. Multi-replication (replica_num+nof_replica_num) provides cross-node fault tolerance — the same object is replicated across multiple physical nodes, so that if one node fails, other replicas remain readable. This document analyzes the current state of the multi-replica mechanism, including allocation logic, failure handling behavior, and potential gaps.1. Replica Allocation Mechanism
1.1 Allocation Entry Point
Replica counts are specified via
ReplicateConfiginPutStart/UpsertStartrequests:replica_num— number of Memory replicasnof_replica_num— number of NoF (NVMe-oF) SSD replicasCore allocation function
AllocateAndInsertMetadata(master_service.cpp:2838):1.2 Cross-Node Placement Guarantee
AllocationStrategy::Allocate()uses aused_segmentsset to ensure different replicas of the same object are placed on different segments:The allocation strategy achieves physical dispersion by distributing memory blocks across different segments.
GetReplicaSegmentNames()returns the list of segment names where all replicas reside.Two built-in strategies:
RandomAllocationStrategy— random selection, up to 100 retriesFreeRatioFirstAllocationStrategy— prefers segments with the highest free ratio, balancing load1.3 Three Write Modes (
ReplicaWriteMode)SINGLE_REPLICAreplica_num=1 && nof_replica_num=0FLEXIBLE_DUAL_REPLICAreplica_num=1 && nof_replica_num=1RELIABLE_MULTI_REPLICAFLEXIBLE_DUAL_REPLICAis an interesting degradation design: Memory and NoF back each other up; if only one can be allocated, it still counts as success.2. Replica Handling on Node Failure
2.1 Core Function:
ClearInvalidHandlesmaster_service.cpp:1904— triggered when a client expires (TTL timeout) or a segment is unmounted:ClearInvalidHandlesiterates over all tenant metadata, callingCleanupStaleHandlesfor each object:!metadata.IsValid()), the entire object metadata is also deleted2.2 Key Behavior: Delete-Only, No Replenishment
After removing invalid replicas, the replica count drops from N to N-1 (or 0). No automatic rebuild is triggered.
On node failure:
replica_num=2, one replica on the failed node, one on a healthy node→ invalid replica deleted, 1 replica remains in service (not reduced to 0)
replica_num=1, the only replica is on the failed node→ invalid replica deleted, 0 remain → object metadata deleted → data loss
2.3 Absence of Automatic Repair
A full search of the
mooncake-storesource tree:auto_repairreplenishrebalancerepairThere is no logic anywhere for automatic replica replenishment.
2.4
ReplicaStatus::FAILEDDefined but Unusedreplica.h:51definesReplicaStatus::FAILEDwith the comment "can be used for reassignment", yet no code in the current codebase marks a replica as FAILED or triggers reallocation based on this state. The existence of this enum value suggests the author reserved an entry point for replica reassignment at design time, but it was never implemented.2.5 Practical Impact
3. Summary — Current Reliability Gap
The current multi-replica mechanism provides "static allocation + passive deletion" but lacks an "active repair" step:
4. Discussion Topics
The following improvement directions are proposed based on the analysis above:
Automatic Replica Repair: When
ClearInvalidHandlescauses the replica count to fall below the desired level, should the system automatically trigger replica rebuild (allocate a new replica on a healthy node + copy data from an existing healthy replica)?Implementing
ReplicaStatus::FAILED: The FAILED status is defined but unused — the comment "can be used for reassignment" suggests it was intended as a reassignment entry point. Should it serve as the starting state for an automatic repair state machine?Recording the Desired Replica Count: Currently, metadata stores only the actual
replicas_list with no record of the "desired replica count", meaning the system does not know how many replicas were originally requested after a failure. Should this be persisted?--replica_numGlobal Default: Currently,replica_numinPutStart/UpsertStartis entirely caller-specified, and the Master has no command-line global default. Should startup flags--replica_num/--nof_replica_numbe added as a fallback?Semantics: "default value + per-request override":
PutStartwithoutreplica_num→ uses CLI defaultPutStartwithreplica_num=3→ uses the request's own value5. Key Source Code Index
ReplicaStatusenummooncake-store/include/replica.hReplicaWriteModemodesmooncake-store/include/replica.hmooncake-store/src/master_service.cppAllocateAndInsertMetadata(line 2838)mooncake-store/src/master_service.cppHasExpectedReplicaAllocation(line 121)mooncake-store/src/master_service.cppClearInvalidHandles(line 1904)mooncake-store/src/master_service.cppCleanupStaleHandles(line 4797)mooncake-store/include/master_service.hObjectMetadata::IsValid(line 1141)mooncake-store/include/master_service.hGetReplicaSegmentNames(line 1148)mooncake-store/include/allocation_strategy.hmooncake-store/include/allocation_strategy.hRandomAllocationStrategy::Allocate(line 226)mooncake-store/include/allocation_strategy.hFreeRatioFirstAllocationStrategy::Allocate(line 406)mooncake-store/src/master_service.cppmooncake-store/src/master_service.cppBefore submitting a new issue...
@github-actions[bot] commented on GitHub (Jul 14, 2026):
Thanks for opening this issue, @liangxu2000!
258133064A maintainer will triage this when possible. To help us respond faster, please include:
Useful links: Documentation · Contributing guide
@github-actions[bot] commented on GitHub (Oct 13, 2026):
This issue has had no activity for 90 days and will be closed in 7 days if there is no further activity. Please comment or react if it should stay open.
@github-actions[bot] commented on GitHub (Oct 21, 2026):
Closing due to 3 months of inactivity. If this is still relevant, please comment and we can reopen.