StackExchange / StackExchange/StackExchange.Redis

Frequent RedisConnectionExecption errors popping up after a certain uptime in Docker containers (Swarm)

Open
#2,975 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.2k
Forks
1.6k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Hi, we've been dealing with tons of these errors randomly popping up after 24+ hours of container uptime. I don't know if this is an issue on our end as everything we use with Valkey / Redis with other clients on the same docker network configuration and manages to hold up well without issues for our users.

Error example:

[13:25:27 ERR] An unhandled exception has occurred while executing the request.StackExchange.Redis.RedisConnectionException: No connection (requires writable - not eligible for replica) is active/available to service this operation: SET user:id:<REDACTED>:lock, mc: 1/1/0, mgr: 10 of 10 available, clientName: b3-backend, IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=2,Free=32765,Min=3,Max=32767), POOL: (Threads=4,QueuedItems=0,CompletedItems=161269,Timers=6), v: 2.9.32.54708

Connection setup

builder.Services.AddSingleton<IConnectionMultiplexer>(sp =>
{
    var config = builder.Configuration.GetConnectionString("Valkey")
                 ?? throw new ArgumentNullException("Valkey connection string");

    var options = ConfigurationOptions.Parse(config);
    
    options.AbortOnConnectFail = false;
    options.ConnectRetry = 3;
    options.ReconnectRetryPolicy = new ExponentialRetry(5000);
    options.ClientName = "b3-backend";
    options.KeepAlive = 30;
    options.AllowAdmin = true;

    return ConnectionMultiplexer.Connect(options);
});

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported ConnectionMultiplexer setup and ConfigurationOptions.Parse call, then investigate the writable/replica exception in a Valkey or Redis Docker Swarm deployment that has been running for 24+ hours. Correlate connection and topology events with the failure; done requires a reproducible cause and a confirmed fix or configuration requirement.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker, redis
Domain
backend, databases, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.