mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[GH-ISSUE #4459] [RFC][Store]: Settle segment.name cardinality and consolidate derived-index ownership in segment lifecycle #1126
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#1126
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 @LinyuWang on GitHub (Oct 3, 2026).
Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/4459
[RFC][Store]: Settle
segment.namecardinality and consolidate derived-index ownership in segment lifecycleSummary
The segment lifecycle code in
mooncake-store/src/segment.cppmaintains several derived indexes overmounted_segments_(client_segments_,client_by_name_,segment_id_by_name_,segments_by_host_, plusAllocatorManager). These indexes currently encode two contradictory assumptions about the cardinality ofsegment.name:client_by_name_andsegment_id_by_name_arename → single valuemaps (include/segment.h:481-483)AllocatorManager(name → list of allocators) andsegments_by_host_(name →set<UUID>,include/segment.h:23) are 1:NThe write path never enforces either assumption, and the delete paths compensate locally with conditional logic. This RFC proposes to settle the cardinality question and give the derived indexes a single point of ownership.
Problem
1. Duplicate names are accepted, but not consistently supported
On the client side, every
MountSegmentAndGetId()call generates a fresh randomsegment.id, whilesegment.name = local_hostname_is constant per client (client_service.cpp:3529-3530). A client mounting N non-overlapping buffers therefore produces N segments with the same name and different ids. Master-side dedup checks onlysegment.id(segment.cpp:228), so all of them mount successfully.Consequences:
client_by_name_[name] = client_idandsegment_id_by_name_[name] = segment.idare silently overwritten (last-wins) (segment.cpp:277-278).IsSegmentAllocatable(name)/GetSegmentStatusByName(name)answer for the latest mounted id only (segment.cpp:1090-1115).2. Order-dependent erase semantics in
CommitUnmountSegment(
segment.cpp:503-510)The
== segment_idguard protects the remount-vs-late-unmount race:PrepareandCommitrun under separate lock scopes, so a same-name remount (new id) can interleave between them, and the guard keeps the stale Commit from stealing the new registration's entries. However:client_by_name_[name]while other same-name segments are still alive and allocatable:ExistsSegmentNamereturns false,GetOwnerClientIdreturns nullopt (SSD free-ratio ranking silently degrades to the default), andIsSegmentAllocatablereturns false for a healthy segment. Unmounting in the opposite order happens to stay correct — i.e. the name-level view depends on unmount order.segment_id_by_name_.3. Redundant, idempotency-based index maintenance
RemoveHostSegmentis called fromPrepareUnmountSegment,PrepareGracefulUnmountSegment,CommitUnmountSegment, and the NoF unmount path;AddHostSegmentfrom four mount/remount/restore paths. Every new lifecycle path must remember to keep five derived structures mutually consistent, and the safety net is idempotent re-execution rather than single ownership. This is the class of debt that produced both #4211 and the asymmetry above.Proposed directions (pick one)
A. Admit 1:N. Change
client_by_name_/segment_id_by_name_toname → set<UUID>; Commit erases the id and cascadesclient_by_name_only when the set becomes empty; consumers adopt any-OK semantics. This matches whatAllocatorManagerandsegments_by_host_already do, and supports multi-NUMA / mixed-media mounts by one client.B. Enforce uniqueness. Reject a second same-name mount (return
SEGMENT_ALREADY_EXISTS, or require explicitly distinct names such asip:port#tag); erase paths become unconditional; documentsegment.nameas a unique key.Either direction removes the conditional erase, the circular id→name→id lookup, and the unmount-order dependence.
Relation to existing work
MountedRegionCatalogplans "client, name, host, and status indexes"; the name-cardinality decision is a prerequisite design input for that catalog, and the catalog is the natural home for single-ownership index maintenance.Discussion questions
MountedRegionCatalog, or tracked independently?Before submitting a new issue...
@github-actions[bot] commented on GitHub (Oct 3, 2026):
Thanks for opening this issue, @LinyuWang!
10942216A maintainer will triage this when possible. To help us respond faster, please include:
Useful links: Documentation · Contributing guide