diff --git a/mooncake-store/src/master_service.cpp b/mooncake-store/src/master_service.cpp index 746e5d2539..c762abd90d 100644 --- a/mooncake-store/src/master_service.cpp +++ b/mooncake-store/src/master_service.cpp @@ -1128,11 +1128,22 @@ auto MasterService::ReMountSegment(const std::vector& segments, .get_memory_descriptor() .buffer_descriptor; SegmentRestore* match = nullptr; + SegmentRestore* endpoint_match = nullptr; + size_t endpoint_match_count = 0; for (auto& restore : restores) { if (descriptor.transport_endpoint_ == restore.segment.te_endpoint || descriptor.transport_endpoint_ == restore.segment.name) { + endpoint_match = &restore; + ++endpoint_match_count; + if (descriptor.buffer_address_ < + restore.segment.base || + descriptor.buffer_address_ - + restore.segment.base >= + restore.segment.size) { + continue; + } if (match != nullptr) { ambiguous_endpoint = true; return; @@ -1140,6 +1151,18 @@ auto MasterService::ReMountSegment(const std::vector& segments, match = &restore; } } + // Preserve endpoint-only matching when it is + // unique so allocator restoration validates + // descriptor bounds. Shared endpoints (e.g. + // UB per-NUMA segments) require one address + // range match to disambiguate the segment. + if (endpoint_match_count == 1) { + match = endpoint_match; + } else if (endpoint_match_count > 1 && + match == nullptr) { + ambiguous_endpoint = true; + return; + } if (match != nullptr) { if (descriptor.protocol_ == "cxl") { unsupported_cxl = true;