Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion mooncake-store/src/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,9 @@ SegmentSerializer::Serialize() {
}
std::sort(sorted_keys.begin(), sorted_keys.end());

packer.pack_array(2 + sorted_keys.size() * 2);
// Trailing ssd_total_capacity_bytes so a restored master keeps the
// client-reported SSD capacity across a snapshot restore (#2783).
packer.pack_array(2 + sorted_keys.size() * 2 + 1);
packer.pack(segment->enable_offloading);
packer.pack(static_cast<uint64_t>(sorted_keys.size()));

Expand All @@ -692,6 +694,7 @@ SegmentSerializer::Serialize() {
packer.pack(task.key);
packer.pack(task.size);
}
packer.pack(segment->ssd_total_capacity_bytes);
}

// Compress entire data
Expand Down Expand Up @@ -1089,6 +1092,17 @@ tl::expected<void, SerializationError> SegmentSerializer::Deserialize(
}
}

// ssd_total_capacity_bytes is appended after the offloading
// objects. Pre-#2783 snapshots omit it, so read it only when
// present; otherwise it keeps the default 0 until the client
// re-reports capacity.
size_t capacity_idx = 2 + count * 2;
if (client_value.via.array.size > capacity_idx &&
IsMsgpackInteger(client_value.via.array.ptr[capacity_idx])) {
segment->ssd_total_capacity_bytes =
client_value.via.array.ptr[capacity_idx].as<int64_t>();
}

segment_manager_->client_local_disk_segment_[client_id] =
std::move(segment);
}
Expand Down
Loading