How To Solve Write Redis Connection Exception

How To Solve Write Redis Connection Exception

這篇介紹How To Solve Write Redis Connection Exception。

錯誤訊息

1
2
3
4
5
6
7
8
9
10
11
12
Unable to write command into connection! Increase connection pool size.
Node source: NodeSource [slot=6788, addr=null, redisClient=null, redirect=null,
entry=null], connection: RedisConnection@1298803612 [redisClient=[addr=redis:
//x.x.x.x:8000], channel=[id: 0xb80b5701, L:/x.x.x.x:56580 ! R:x.x.x.x/x.x.x.x
:8000], currentCommand=null, usage=1], command: (EVAL), params: [local v =
redis.call('hget', KEYS[1], ARGV[1]); redis.call('hset', KEYS[1], ARGV[1],
ARGV[2]); retur..., 1, baccarat:staging:monitorcache, PooledUnsafeDirectByteBuf
(ridx: 0, widx: 119, cap: 256), PooledUnsafeDirectByteBuf(ridx: 0, widx: 217,
cap: 256)] after 3 retry attempts
org.redisson.client.WriteRedisConnectionException: Unable to write command into
connection! Increase connection pool size. Node source: NodeSource [slot=6788,
addr=null, redisClient=null, redirect=null, entry=null], connection:

官方提供解決方案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
There are four main reasons:

All netty threads are busy, leading to delays in both Redis response decoding
and sending commands to Redis All connections are busy
Redis server takes too long to respond the request.
Sync methods invocation in async/reactive/rx listeners.
First try to set follow values for nettyThreads setting: 32, 64, 128, 256 this
allow Redisson to get free netty thread to decode response or send command.
Next, try to increase retryInterval and/or
timeout to a reasonable value so that a command can still gracefully fail
without having the end user wait forever. At the last step, try to increase
connection pool setting so that Redisson can stand
a better chance in getting a free connection.

Complex commands such as keys, hmget and big loops in Lua scripts are
more likely to see it than other commands. It is important to understand
an operation can still timeout despite the absence
of it from the Redis slowlog. Slowlogs only record the time a command
is been processed by the Redis event loop and not anything before or after.
Network issue may also cause this exception
when a response is still in-flight.