-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
[Performance] RedisRemoteEvictionExtension evicts just added key from all running instances #177
Comments
Thanks for raising this issue - that is pretty strange, will dig into the code in the next day or two to get it sorted. It definitely shouldn't be doing what you've described. |
Here is the call stack which happens. GetOrSetAsync Let me know if I can help you with anything. I could try to write unit test and fix the thing but not sure where is the most correct place to break the eviction chain. |
The call stack is super helpful. I get why it is doing that and it even makes sense but yeah, logically it needs to consider not evicting fresh items in a cache. It should only play out like that for older existing items. The solution might be checking the expiry on the receiving eviction extension that it is within X seconds of being set itself. |
How about changing interface of ICacheChangeExtension.OnCacheUpdateAsync to something like ValueTask OnCacheUpdateAsync(string cacheKey, DateTime expiry, bool newEntry) then eviction could be easily skipped and maybe the new parameter will be helpful also for other extensions? |
Yeah, something like that could work. Because I'm thinking there are two states:
Basically all calls to I've recreated your issue as a test case in #178 and plan to do the change tomorrow, hopefully with a new release in the next day or two. |
Version 0.11.0 of Cache Tower is now released with the fix from #178 included - that should solve your problem. If you're still encountering issues, let me know! |
I confirm that issue is fixed in version 0.11.0. Thank you. |
What does the bug do?
Even though the key was just added to cache the eviction is called on all currently running instances. Which makes startup performance really bad when a lot of new keys are added to cache.
So when calling GetOrSetAsync even though key is not present in any layer of cache it still get's evicted from memory layer from all other instances which makes a lot of overhead when adding new keys ( especially startup).
How can it be reproduced?
You can reproduce the bug by running this code...
The text was updated successfully, but these errors were encountered: