Repository navigation
[Bugfix][Store] Make local MEMORY preference independent of replica order - #3662
Conversation
…upport SSD offloading (kvcache-ai#3658) When SSD offloading is enabled, some data resides on SSD instead of in-memory. batch_get_session_start was using SelectCompleteMemoryReplica which only selects memory replicas, causing INVALID_REPLICA (702) errors for keys whose replicas exist only on SSD. Fix: replace SelectCompleteMemoryReplica with SelectBestReplica, which handles all replica types (memory, SSD, disk, DFS) and picks the best available one, matching the behavior of batch_get_into and other get methods. Co-Authored-By: Claude <noreply@anthropic.com>
Two bugs in PR kvcache-ai#3662: 1. SelectBestReplica priority: scan all replicas before returning so local MEMORY always beats local NOF regardless of list order. Previously the first local replica (memory or NOF) caused an early return, so [local NOF, local MEMORY] would incorrectly select NOF. 2. batch_get_into_multi_buffer_ranges replica_limit: NOF replicas also support range reads via RDMA. Use the NOF buffer size for overflow detection instead of 0, which caused INVALID_PARAMS for any NOF replica selected by batch_get_session_start. Co-Authored-By: Claude <noreply@anthropic.com>
|
@fcczzz @bitborne Fixed both issues: 1. Priority ordering bug (bitborne): 2. NOF replica_limit=0 bug (fcczzz): |
…(issue kvcache-ai#3658) Covers both permutations (local NOF before local MEMORY, and vice versa) to lock in the order-independent priority fix in SelectBestReplica.
|
Thanks @fcczzz and @bitborne for digging into the two selection issues, and @XFDG for fixing the order-dependent MEMORY/NoF choice. That part looks good now. I think the session-read concern is still only halfway resolved, though. Could we either add the NoF range-transfer path end to end, or keep session selection restricted to the replica types that |
…vcache-ai#3658) The session range-read path is memory-only: Client::BatchTransferReadRanges rejects every non-MEMORY replica (client_service.cpp), so a session started against a NOF_SSD replica passes the size/overflow check and then fails the actual transfer with INVALID_PARAMS, and a LOCAL_DISK/DFS/DISK selection fails even earlier with a zero replica_limit. The previous revision switched batch_get_session_start to SelectBestReplica, which can return NOF_SSD (and lower tiers). Restore a MEMORY-only selector for the session path: move SelectCompleteMemoryReplica into replica_selection.h (next to SelectBestReplica) so it is unit-testable, and use it in batch_get_session_start. The single-object get path keeps SelectBestReplica, which correctly routes NOF/DISK/DFS through Client::Get. The kvcache-ai#3658 fix (local MEMORY preferred over local NOF regardless of master return order) is preserved: SelectCompleteMemoryReplica scans all replicas and prefers a local MEMORY replica. Adds SessionPathRejectsNoFOnlyObject: a NOF-only object is selected by SelectBestReplica (single-object path) but declined by SelectCompleteMemoryReplica (session path), and a local MEMORY replica still wins when both MEMORY and NOF are present. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks @catyans — you're right, and I confirmed it end to end. I took the second option you offered — keep session selection restricted to the replica types Fixed in
New regression One note on the |
|
CI note (not a code change): the one red leg — Evidence:
All logic-relevant checks are green: |
catyans
left a comment
There was a problem hiding this comment.
Thanks for tracing this all the way through. LGTM.
Restricting session start to complete MEMORY replicas now matches what BatchTransferReadRanges() can actually execute, so a NoF-only object is rejected up front instead of failing halfway through the session. The new selector still preserves the order-independent local-MEMORY preference that @fcczzz and @bitborne called out, and the focused test captures both sides of that contract nicely.
The remaining Ubuntu 22.04 failure is in the known SSD concurrent-stress path and doesn't exercise this session-selection change, so I don't see it as a blocker for this fix.
|
The current MEMORY-only session selection matches BatchTransferReadRanges, and the order-independent local MEMORY preference looks correct. However, the session selector and start/read/end behavior are unchanged from the merge base, so SSD-only objects still fail session start with INVALID_REPLICA. Please update the title and description, remove “Fixes #3658”, and coordinate the overlapping priority fix with #3742. The latest CI run also failed. |
|
Good catch, @fcczzz. I agree the current title/body overstate what this head does. My approval was for the safety correction—keeping the session path MEMORY-only so it cannot cache a replica that @XFDG, could you retitle/rewrite the PR around the actual replica-priority fix, remove |
|
Thanks @fcczzz and @catyans for the precise review. Done in this update:
The code itself is unchanged — @catyans's approval covers the safety correction (MEMORY-only session start) and the order-independent |
|
@Icedcoco @2sumtech @catyans I narrowed #3662 in commit |
Description
SelectBestReplicadocuments the prioritylocal MEMORY > local NOF_SSD > remote MEMORY > remote NOF_SSD, but it previously returned the first complete local MEMORY or NOF replica encountered. As a result,[local NOF, local MEMORY]selected NOF while the reverse ordering selected MEMORY.This PR makes the documented priority independent of the order returned by the master.
Change
The selector scans all complete MEMORY and NOF candidates before deciding, records local and remote candidates separately, and then applies the existing priority. Other replica tiers and remote-replica scoring behavior remain unchanged.
Regression coverage
LocalMemoryBeatsLocalNoFInBothOrders: local MEMORY wins in both permutations.IncompleteLocalMemoryFallsBackToLocalNoF: an unreadable local MEMORY candidate does not hide a usable local NOF replica.LocalNoFPrecedesRemoteMemory: locality still outranks a remote MEMORY candidate.The final two guard cases were adapted from
2sumtech/Mooncake@67bfff5d, as coordinated in #3742.Scope coordination
batch_get_session_start, session replica selection, or ranged-session execution.Module
mooncake-store)Type of Change
How Has This Been Tested?
The focused regression tests are included in
replica_selection_test.cpp. No additional local test run was performed after the final scope reduction; the refreshed upstream CI run validates the current head.AI Assistance Disclosure