-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clearing LFU cache doesn't actually clear it #399
Comments
Update: I tested with |
I would have thought that calling |
You beat me to it - I was going to try with I think the reason What isn't clear to me is how the unit test for this can pass. I will debug this in detail. |
I looked at this some more yesterday - the code is wrong and leaves orphan nodes in the window/probation/protected LRUs. These are the bogus items you observed in the probation LRU. The unit test I have passes because it only validates via the count and whether the removed keys exist. Both count and exists are based on the internal dictionary. In your test, it is possible background maintenance runs before I will fix this so that the write buffer items are not dropped. I will also implement an integrity check in the tests to validate the internal data structures are in a consistent state to prevent re-introducing this bug. Last month I added some soak tests for |
Hey @bitfaster! 👋🏻 I think we're bumping up against the same bug. Can you confirm this also affects Is there a workaround? Looping through entries and calling We're using v2.2.1. UPDATE: Looping with |
Moved repro to #402 |
I have a situation where clearing the cache doesn't work. I can reproduce it with the following test case:
When I run this test, it fails most of the times, but occasionally succeeds. When it fails,
emptyCount
varies from 2 to 7.When I debugged the real situation, I ended up in
ConcurrentLfu.Trim
. Here, I noticed that:this.Count
was 3.this.probationLru
had something like 26 nodes in it - but it looked like multiple nodes had the same key.TakeCandidatesInLruOrder
produced 3 candidates.TryRemove
failed to remove the candidates.Debugging from the test has the same pattern -
TryRemove
fails sincethis.dictionary
doesn't contain the candidate, so it appears to be out of sync.I know that there is some sort of async maintenance going on (that's why I try to force maintenance in the test with the second
Clear
), but in the application where the cache is used, the entries don't go away even after a while - the count is stuck at non-zero after clearing.The text was updated successfully, but these errors were encountered: