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

Deadlock while awaiting Task from Database using disposed/closed ConnectionMultiplexer #2412

Closed
tinix0 opened this issue Mar 27, 2023 · 2 comments · Fixed by #2408
Closed

Comments

@tinix0
Copy link

tinix0 commented Mar 27, 2023

Hi, I ran into the following situation. When having connection issues, closing or disposing the ConnectionMutex can cause some in flight requests to not cancel or timeout.

We've discovered this, because we have some convoluted connection restoration logic in our microservices that tries to throw away the multiplexer if there are too many failed requests and sometimes this logic causes the service to become stuck, because redis calls do not return.

I have reduced the issue to this minimal example:

ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
var db = redis.GetDatabase();
var result = db.StringSetAndGetAsync("a", "b", null, When.Always, CommandFlags.None); // Breakpoint here and stop the redis server, then resume  the program
redis.Close();
Console.WriteLine(await result.ToString()); // Hangs forever

I would expect the await to throw in this situation, not to hang.

@mgravell
Copy link
Collaborator

This looks very similar to something we're already investigating (and have a plan for), but I'll be sure to ensure we consider this example too, thanks.

@NickCraver
Copy link
Collaborator

A fix for this is now available in https://www.nuget.org/packages/StackExchange.Redis/2.6.104 (currently unlisted) if anyone wants to grab it early

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