mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[PR #1363] [CLOSED] [Store] Add HTTP metadata cleanup on client timeout #2194
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#2194
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?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/Mooncake/pull/1363
Author: @chenkaiyue
Created: 1/12/2026
Status: ❌ Closed
Base:
main← Head:metadata_cleanup📝 Commits (1)
694d48dfeat(master): Add HTTP metadata cleanup on client timeout📊 Changes
8 files changed (+141 additions, -4 deletions)
View changed files
📝
mooncake-store/include/http_metadata_server.h(+9 -0)📝
mooncake-store/include/master_config.h(+4 -0)📝
mooncake-store/include/master_service.h(+19 -0)📝
mooncake-store/include/rpc_service.h(+6 -1)📝
mooncake-store/src/http_metadata_server.cpp(+21 -0)📝
mooncake-store/src/master.cpp(+38 -1)📝
mooncake-store/src/master_service.cpp(+38 -0)📝
mooncake-store/src/rpc_service.cpp(+6 -2)📄 Description
Description
This PR adds a new feature that allows the Master Service to automatically clean up HTTP Metadata Server entries when a client heartbeat times out. This cleanup functionality is controlled by a new configuration flag
--enable_metadata_cleanup_on_timeoutand only works when the HTTP Metadata Server is deployed alongside the Master Service (--enable_http_metadata_server=true).Problem
In Mooncake's distributed KV cache architecture, there are two services that store client metadata:
mooncake/ram/{segment_name}) and RPC routing information (mooncake/rpc_meta/{segment_name}).When a client (e.g., SGLang inference server) terminates normally, it performs cleanup operations to both services:
UnmountSegment()to the Master ServiceremoveSegmentDesc()andremoveRpcMetaEntry()to the HTTP Metadata ServerHowever, when a client crashes or is forcefully terminated (e.g.,
kill -9, OOM killed, node failure), the cleanup operations may fail or never execute. The Master Service can detect this through heartbeat timeout (client_ttl) and clean up its internal segment resources, but the HTTP Metadata Server has no heartbeat mechanism and cannot detect client failures.This leads to stale metadata residue on the HTTP Metadata Server:
mooncake/ram/{segment_name}- Contains outdated RDMA buffer informationmooncake/rpc_meta/{segment_name}- Contains stale RPC connection detailsThese residual entries can cause issues when:
Solution
Leverage the Master Service's existing heartbeat mechanism to clean up HTTP Metadata Server entries when client timeout is detected:
Design Decisions
Opt-in Feature: Disabled by default (
--enable_metadata_cleanup_on_timeout=false) to ensure backward compatibility.Coupled Deployment Only: This feature only works when the HTTP Metadata Server is co-located with the Master Service. If
enable_http_metadata_server=falsebutenable_metadata_cleanup_on_timeout=true, a warning is logged and the cleanup feature is automatically disabled.Direct Memory Access: Since both services run in the same process when co-deployed, the Master Service directly calls
HttpMetadataServer::removeKey()without network overhead.Key Prefix Support: Respects the
MC_METADATA_CLUSTER_IDenvironment variable for custom key prefixes.Changes
Configuration (
mooncake-store/include/master_config.h)enable_metadata_cleanup_on_timeoutboolean field toMasterConfigstructMain Entry (
mooncake-store/src/master.cpp)--enable_metadata_cleanup_on_timeoutcommand-line flagHttpMetadataServerpointer toWrappedMasterServicewhen cleanup is enabledHTTP Metadata Server (
mooncake-store/include/http_metadata_server.h,mooncake-store/src/http_metadata_server.cpp)removeKey(const std::string& key)method for single key deletionremoveKeys(const std::vector<std::string>& keys)method for batch deletionstore_mutex_Master Service (
mooncake-store/include/master_service.h,mooncake-store/src/master_service.cpp)HttpMetadataServer* http_metadata_server_membersetHttpMetadataServer(HttpMetadataServer* server)methodcleanupHttpMetadata(const std::string& segment_name)methodClientMonitorThreadMain()when processing expired clientsRPC Service (
mooncake-store/include/rpc_service.h,mooncake-store/src/rpc_service.cpp)WrappedMasterServiceconstructor to accept optionalHttpMetadataServer*parameterMasterServicewhen providedUsage
To enable this feature:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.