StackExchange/StackExchange.Redis

What't the possible reason of StackExchange.Redis.RedisTimeoutException?

maomaomqiu opened this issue · 0 comments

Hi ~
I encounter RedisTimeoutException in such condition

loopCount = 0;

await using var keys = server.KeysAsync(pattern: pattern).GetAsyncEnumerator();
bool isLastkey = !await keys.MoveNextAsync();

while (not processed all keys)
{
    if (loopCount % 100 == 0) 
    {
        await Task.Delay(SleepIntervalInMs);
    }
    // logic of process keys ..
    loopCount++;
}

PS, I use below settings to initial Redis connection

private static ConfigurationOptions ConfigureConnection(string redisConnectionString)
{
    if (redisConnectionString == null)
    {
        return null;
    }

    ConfigurationOptions config = ConfigurationOptions.Parse(redisConnectionString);
    config.AbortOnConnectFail = false;
    config.SyncTimeout = 5000;
    
    // Permits administrative actions such as checking memory usage.
    config.AllowAdmin = true;

    return config;
}

when I try SleepIntervalInMs as 50 ms, it seems won't introduce timeout exceptions in my testing
But it could increase operation per second peak

So I let it be 500 ms, it could introduce timout exception

StackExchange.Redis.RedisTimeoutException: The message timed out in the backlog attempting to send because no connection became available, command=SCAN, timeout: 5000, outbound: 0KiB, inbound: 0KiB, inst: 0, qu: 403, qs: 0, aw: False, bw: CheckingForTimeout, rs: ReadAsync, ws: Idle, in: 0, last-in: 1, cur-in: 0, sync-ops: 0, async-ops: 31, serverEndpoint: ***, conn-sec: 10.89, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: **.Redis-v2.7.10.12442), IOCP: (Busy=0,Free=1000,Min=128,Max=1000), WORKER: (Busy=1,Free=32766,Min=256,Max=32767)

I decide to tune config.SyncTimeout larger, I think this could mitigate that issue

from doc I know, the error msg mean 0 request send from Redis Client to Redis Server.

Could anyone help me figure out why time out exception could happen?