-
-
Notifications
You must be signed in to change notification settings - Fork 37
Description
What does the bug do?
GetOrSetAsync
call for particular cacheKey
sometimes hangs for an infinite time.
I think the reason of the behaviour is this TaskCompletionSource
which can be created, for intance, when 2 threads getting value for a first time in parallel (cache miss), and thread A goes to this branch of code , thread B goes to this branch of code, sleeps for a while, and then calls KeyLock.WaitAsync(cacheKey)
when the KeyLock
is already released by thread A.
Then, Thread B waits for the TaskCompletionSource
just created by itself, and from the thread perspective it looks like infinite call of GetOrSetAsync
method, and only another thread calling GetOrSetAsync
with the same cacheKey
can release Thread B from this block.
Not sure, but it looks like even this another thread call won't help if it happens after cacheEntry
(created by thread A) is expired.
How can it be reproduced?
In my case it could only be reproduced under (relatively) heavy load.
Environment (if applicable)
- NuGet Package Version: 0.14.0
- .NET Runtime Version: .NET 8
- Operating System: Linux