Hi,
We had issues with a web site of ours that freezes from time to time. Looking at the process dumps, there's thousands of threads (initiated by web requests) waiting for a lock in the Eval method in RedisCacheHandle.cs, which is on this line as far as I can see:
It seems as the reason for that is that one single thread is stuck in RetryHelper.cs, waiting forever for a Task.Delay on this line, that I guess was called because there was some temporary Redis server issue:
|
Task.Delay(timeOut).Wait(); |
Doing .Wait() on a awaitable could AFAIK cause deadlocks when in ASP.NET request context because the synchronization context cannot be restored when the continuation is run: https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html
I guess a workaround would be to add ConfigureAwait to avoid deadlock even though it's sort of a hack:
Task.Delay(timeOut).ConfigureAwait(false).GetAwaiter().GetResult();
Or just use Thread.Sleep(timeOut) in this case, or am I missing something?
Hi,
We had issues with a web site of ours that freezes from time to time. Looking at the process dumps, there's thousands of threads (initiated by web requests) waiting for a lock in the Eval method in RedisCacheHandle.cs, which is on this line as far as I can see:
CacheManager/src/CacheManager.StackExchange.Redis/RedisCacheHandle.cs
Line 977 in 4385c06
It seems as the reason for that is that one single thread is stuck in RetryHelper.cs, waiting forever for a Task.Delay on this line, that I guess was called because there was some temporary Redis server issue:
CacheManager/src/CacheManager.StackExchange.Redis/RetryHelper.cs
Line 43 in 3f3ad35
Doing .Wait() on a awaitable could AFAIK cause deadlocks when in ASP.NET request context because the synchronization context cannot be restored when the continuation is run: https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html
I guess a workaround would be to add ConfigureAwait to avoid deadlock even though it's sort of a hack:
Task.Delay(timeOut).ConfigureAwait(false).GetAwaiter().GetResult();Or just use
Thread.Sleep(timeOut)in this case, or am I missing something?