Closed hakakou closed 7 months ago
So this appears to be a symptom of another problem. I enabled logging and noticed that it was repeatedly logging "Cache Missed : cachekey = test-en.json".
The core issue appears to be that the keys.dat (and therefore the _cacheKeysMap in the disk caching provider) somehow gets into a broken state with a lock set for the cache key that is never cleared for some reason.
The TryAdd returns false here as there is an existing lock https://github.com/dotnetcore/EasyCaching/blob/914d7e8027fd1202ddb50d9f4ece5e10fc72fa20/src/EasyCaching.Disk/DefaultDiskCachingProvider.Async.cs#L130-L134
If sleeps for SleepMs
and calls GetAsync which starts another recursion. Since the lock is never released, we end up with a stackoverflow after a number of failures.
Even restarting the app doesn't seem to resolve it as the lock is stored in the keys.dat
Here is my keys.dat
C:\Dev\.cache\test.json_Lock
C:\Dev\.cache\test.html
5E88E187872DFD1AA0F7882D94D324FF
C:\Dev\.cache\test.css
Maybe the provider should remove, or at least ignore any existing locks in the cacheKeyMap on start? Or there should be a limit to the number of retry attempts?
Ideally it shouldn't get into a broken state in the first place, but I'm not sure how that happens.
Description
Stack overflow error in ASP.NET Core IIS points to
EasyCaching.Disk
as culprit.Steps to Reproduce
Cannot reproduce. Happens in random every 2-3 days on IIS server running ASP.NET Core 8 project. Because it's a stack overflow error, the only way to get logs from the process is the following:
1) Add environment variable and restart IIS
2) In web.config, change the following to
Related code
Specifications