Skip to content

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

@tinix0

Description

@tinix0

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions