[Store] Serialize ssd_total_capacity_bytes in local disk snapshot (#2783)#2927
Merged
stmatengss merged 1 commit intoJul 18, 2026
Merged
Conversation
After a master restart with snapshot restore, the SSD total capacity in metrics dropped to 0 (used bytes stayed correct) until the client restarted and re-ran FileStorage::Init (kvcache-ai#2783). SegmentSerializer packed a LocalDiskSegment as [enable_offloading, count, key/task pairs...] and never included ssd_total_capacity_bytes, so the restored segment kept its default 0. Append ssd_total_capacity_bytes to the packed array and read it back when present. Snapshots written before this change lack the trailing field and deserialize unchanged (capacity stays 0 until the client re-reports it), so the format bump is backward compatible. Signed-off-by: Yufeng He <[email protected]>
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Closed
1 task
stmatengss
approved these changes
Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2783. After a master restart with snapshot restore, the SSD total capacity in metrics drops to
0 B(the used-bytes numerator stays correct), and it stays wrong until the client also restarts and re-runsFileStorage::Init:SegmentSerializerpacks aLocalDiskSegmentas[enable_offloading, count, key1, task1, ...]and never includesssd_total_capacity_bytes, so a segment rebuilt from a snapshot keeps its default0until the next client heartbeat that carries capacity (which today only happens on client re-init).This appends
ssd_total_capacity_bytesto the packed array and reads it back when present. Snapshots written before this change lack the trailing field, soDeserializereads it only whenarray.sizeextends past the offloading objects; older snapshots deserialize exactly as before (capacity stays0until the client re-reports it). The format bump is therefore backward compatible — this mirrors the existing legacy-format handling already inDeserialize.Module
mooncake-transfer-engine)mooncake-store)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
The change is confined to the msgpack serialize/deserialize path, so I verified it with a standalone program that replicates the exact
LocalDiskSegmentpack/unpack logic:ssd_total_capacity_bytesintact (2 TiB in the test).enable_offloadingand the offloading objects intact and capacity0— reproducing the pre-fix behavior without crashing on the shorter array.2and still round-trips.Test results:
I didn't wire a repo test through the full snapshot child-process harness (it needs a Linux/etcd environment I can't run locally), but I'm happy to add a
SegmentSerializerround-trip test asserting capacity survives if you'd like one in-tree.Checklist
./scripts/code_format.sh—clang-formatisn't available in my environment; I matched.clang-format(Google, 4-space, 80 cols) by handpre-commit run --all-filesand all hooks pass — toolchain unavailable locally; please let CI run itAI Assistance Disclosure
Claude Code assisted while writing this fix. I've reviewed every changed line, traced the serialize/deserialize indices myself, and verified the round-trip and backward-compatibility with the standalone described above.