From baa16b477ac29b81152aa42fa3878e6e061452c5 Mon Sep 17 00:00:00 2001 From: Wang_YQi Date: Sat, 8 Aug 2026 16:19:51 +0800 Subject: [PATCH 1/2] fix for ub segment --- mooncake-store/src/master_service.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mooncake-store/src/master_service.cpp b/mooncake-store/src/master_service.cpp index e012cebd49..c529b86718 100644 --- a/mooncake-store/src/master_service.cpp +++ b/mooncake-store/src/master_service.cpp @@ -1122,6 +1122,24 @@ auto MasterService::ReMountSegment(const std::vector& segments, restore.segment.te_endpoint || descriptor.transport_endpoint_ == restore.segment.name) { + // When multiple segments share the + // same endpoint (e.g. UB per-NUMA + // segments), disambiguate by + // checking whether the replica's + // buffer address falls within this + // segment's virtual address range + // [base, base+size). Each + // per-NUMA segment occupies a + // contiguous and non-overlapping + // range, so at most one segment + // matches. + if (descriptor.buffer_address_ < + restore.segment.base || + descriptor.buffer_address_ >= + restore.segment.base + + restore.segment.size) { + continue; + } if (match != nullptr) { ambiguous_endpoint = true; return; From 7e49de1b6789760d6c7f3eab6a37d917d9407901 Mon Sep 17 00:00:00 2001 From: BGQ99 <1132767344@qq.com> Date: Sat, 22 Aug 2026 11:44:34 +0000 Subject: [PATCH 2/2] fix(store): preserve remount validation for unique endpoints --- mooncake-store/src/master_service.cpp | 31 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/mooncake-store/src/master_service.cpp b/mooncake-store/src/master_service.cpp index c529b86718..77026ac41f 100644 --- a/mooncake-store/src/master_service.cpp +++ b/mooncake-store/src/master_service.cpp @@ -1117,26 +1117,19 @@ 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) { - // When multiple segments share the - // same endpoint (e.g. UB per-NUMA - // segments), disambiguate by - // checking whether the replica's - // buffer address falls within this - // segment's virtual address range - // [base, base+size). Each - // per-NUMA segment occupies a - // contiguous and non-overlapping - // range, so at most one segment - // matches. + endpoint_match = &restore; + ++endpoint_match_count; if (descriptor.buffer_address_ < restore.segment.base || - descriptor.buffer_address_ >= - restore.segment.base + + descriptor.buffer_address_ - + restore.segment.base >= restore.segment.size) { continue; } @@ -1147,6 +1140,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;