Skip to content
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

distributed cache inconsistencies #240

Open
IntranetFactory opened this issue Apr 27, 2024 · 0 comments
Open

distributed cache inconsistencies #240

IntranetFactory opened this issue Apr 27, 2024 · 0 comments

Comments

@IntranetFactory
Copy link

We used EFCoreSecondLevelCacheInterceptor on a single web server for months without problems. We wanted to scale out by adding more servers and one Redis Sentinel. We quickly recognized problems with records added on one server missing on the others.

We analyzed possible causes and found

  1. that ClearAllCachedEntries is called unexpectedly https://github.com/VahidN/EFCoreSecondLevelCacheInterceptor/blob/master/src/EFCoreSecondLevelCacheInterceptor/EFEasyCachingCoreProvider.cs#L164 wiping out the whole cache

  2. that when multiple servers modify the list of CacheDependencies at the same time in https://github.com/VahidN/EFCoreSecondLevelCacheInterceptor/blob/master/src/EFCoreSecondLevelCacheInterceptor/EFEasyCachingCoreProvider.cs#L91 the resulting list of keys was not consistent on all notes

We created a poc CacheProvider which interacts directly with Redis Sentinel and stores the CacheDependencies in Redis SortedSet:
https://gist.github.com/IntranetFactory/09338b44aa3c6ad7b2cab0284acfe14c

That provider does not need ClearAllCachedEntries and provides consistent distributed caching for us so far.

Is our assumption that https://github.com/VahidN/EFCoreSecondLevelCacheInterceptor/blob/master/src/EFCoreSecondLevelCacheInterceptor/EFEasyCachingCoreProvider.cs#L91 cause inconsistencies with distributed cache when multiple servers modify records in a table at the same time correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant