fix(prefix): prevent evicted hashes from being re-added to hashToPos in indexer#2579
fix(prefix): prevent evicted hashes from being re-added to hashToPos in indexer#2579gyliu513 wants to merge 1 commit intokubernetes-sigs:mainfrom
Conversation
… in indexer - Fix a race condition in `indexer.Add()` where the split-lock pattern (unlock between LRU insertion and `hashToPods` update) allows evicted hashes to be re-added to `hashToPods`. When a single `Add` call passes more hashes than the LRU capacity, later insertions evict earlier ones. The eviction callback correctly removes entries from `hashToPods`, but the second lock section unconditionally re-adds all input hashes — including the evicted ones. This causes `hashToPods` to reference hashes no longer present in the LRU, leading to incorrect prefix-aware routing decisions. - Add `lruForPod.Contains(hash)` check before inserting into `hashToPods` to skip evicted hashes. - Add `TestIndexer_AddEvictsWithinSingleCall` to cover the intra-call eviction scenario.
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gyliu513 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @gyliu513. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
This has been fixed in #2501 |
indexer.Add()where the split-lock pattern (unlock between LRU insertion andhashToPodsupdate) allows evicted hashes to be re-added tohashToPods. When a singleAddcall passes more hashes than the LRU capacity, later insertions evict earlier ones. The eviction callback correctly removes entries fromhashToPods, but the second lock section unconditionally re-adds all input hashes — including the evicted ones. This causeshashToPodsto reference hashes no longer present in the LRU, leading to incorrect prefix-aware routing decisions.lruForPod.Contains(hash)check before inserting intohashToPodsto skip evicted hashes.TestIndexer_AddEvictsWithinSingleCallto cover the intra-call eviction scenario./kind bug
What type of PR is this?
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Does this PR introduce a user-facing change?: