Bug Report
Environment
- Mooncake version:
master branch
- Master config:
enable_snapshot=true, enable_offloading=true
- Client: 1 client, writing 100 KV pairs with SSD offload
Description
After master restarts with snapshot restore, the SSD total capacity (denominator)
in metrics shows 0, while the used space (numerator) is correct:
Before restart: Mem Storage: 400MB / 128GB | SSD Storage: 400MB / 2TB
After restart: Mem Storage: 400MB / 128GB | SSD Storage: 400MB / 0 B
^^^
The issue persists until the client also restarts (re-executes FileStorage::Init).
Root Cause (from source code analysis)
Two things happen:
1. ssd_total_capacity_bytes is not serialized in snapshot
In mooncake-store/src/segment.cpp, the SegmentSerializer serializes LocalDiskSegment with only enable_offloading and the offloading objects list (line ~589-591). The field ssd_total_capacity_bytes is not included.
After deserialize (line ~927-928), a new LocalDiskSegment is created with ssd_total_capacity_bytes = 0 (default value, segment.h:88).
2. file_total_capacity_ gauge is not rebuilt after restore
In TryRestoreStateFromSnapshot() (master_service.cpp), memory capacity is rebuilt after restore (lines 5001-5034), but there is no equivalent logic for file capacity. The file_total_capacity_ gauge remains at its initial value 0.
Note: ReportSsdCapacity RPC is the only runtime path that sets file_total_capacity_, but the client only calls it once at FileStorage::Init() and does not re-report after master restart.
Steps to Reproduce
- Start master with
enable_snapshot=true and enable_offloading=true
- Start 1 client with SSD offload configured (e.g. 2TB capacity)
- Write 100 KV pairs to trigger offloading to SSD
- Observe metrics:
SSD Storage: X / 2TB (correct)
- Restart the master process (client continues running)
- Master restores from snapshot
- Observe metrics:
SSD Storage: X / 0 B (denominator is 0)
Suggested Fix
- Add
ssd_total_capacity_bytes to LocalDiskSegment serialization/deserialization in segment.cpp
- After snapshot restore in
master_service.cpp, rebuild file_total_capacity_ gauge from restored segments, similar to the existing mem capacity rebuild logic (lines 5001-5034)
Before submitting...
Bug Report
Environment
masterbranchenable_snapshot=true,enable_offloading=trueDescription
After master restarts with snapshot restore, the SSD total capacity (denominator)
in metrics shows 0, while the used space (numerator) is correct:
Before restart: Mem Storage: 400MB / 128GB | SSD Storage: 400MB / 2TB
After restart: Mem Storage: 400MB / 128GB | SSD Storage: 400MB / 0 B
^^^
The issue persists until the client also restarts (re-executes
FileStorage::Init).Root Cause (from source code analysis)
Two things happen:
1.
ssd_total_capacity_bytesis not serialized in snapshotIn
mooncake-store/src/segment.cpp, theSegmentSerializerserializesLocalDiskSegmentwith onlyenable_offloadingand the offloading objects list (line ~589-591). The fieldssd_total_capacity_bytesis not included.After deserialize (line ~927-928), a new
LocalDiskSegmentis created withssd_total_capacity_bytes = 0(default value,segment.h:88).2.
file_total_capacity_gauge is not rebuilt after restoreIn
TryRestoreStateFromSnapshot()(master_service.cpp), memory capacity is rebuilt after restore (lines 5001-5034), but there is no equivalent logic for file capacity. Thefile_total_capacity_gauge remains at its initial value 0.Note:
ReportSsdCapacityRPC is the only runtime path that setsfile_total_capacity_, but the client only calls it once atFileStorage::Init()and does not re-report after master restart.Steps to Reproduce
enable_snapshot=trueandenable_offloading=trueSSD Storage: X / 2TB(correct)SSD Storage: X / 0 B(denominator is 0)Suggested Fix
ssd_total_capacity_bytestoLocalDiskSegmentserialization/deserialization insegment.cppmaster_service.cpp, rebuildfile_total_capacity_gauge from restored segments, similar to the existing mem capacity rebuild logic (lines 5001-5034)Before submitting...