出现问题

最近在公司正式环境上发现,在redis做完升降配操作后,不重启服务但是却在使用redis分布式锁的一些代码抛出了异常。这时候重启了服务才能解决这个问题,初步推测是redis连接池中的参数还是保留了原来升降配前的参数,导致连接出现了异常

解决问题

看了错误堆栈:

org.redisson.client.WriteRedisConnectionException: 
Unable to send command! Node source: NodeSource [slot=null, addr=null, redisClient=null, redirect=null, 
entry=MasterSlaveEntry [masterEntry=[freeSubscribeConnectionsAmount=1, freeSubscribeConnectionsCounter=50, freeConnectionsAmount=10, freeConnectionsCounter=64, freezed=false, freezeReason=null, client=[addr=redis://10.10.3.112:6379], nodeType=MASTER, firstFail=0]]], 
connection: RedisConnection@1662347556 [redisClient=[addr=redis://10.10.3.113:6379], channel=[id: 0xb21f069b, L:/10.10.3.117:50884 ! R:10.10.3.113/10.10.3.113:6379]], command: (HGET), 
command params: [shiro-activeSessionCache, ��t$afb4da38-cf18-4117-9159-ce16fc61b9d9] after 3 retry attempts

 

最终,在redisson的github仓库的issue中找到了答案: The connection not reconnect #1811

刚好我们使用的redisson版本也是3.9.1,这个issue发生提到的错误,问题的出现基本和我遇到的一致,并且在Fixed - connection is not reconnected #1811中解决了,所以,这样子,升级!搞定!

问题总结

问题的主要原因是:在redis出问题之后,watchdog发现连接无效之后,然后打印了一个警告日志之后,就没法有自动重连了,导致继续使用该连接的时候出问题,问题解决,ConnectionWatchdog.channelInactive.tryReconnect方法:

解决版本如下,如果遇到相同的问题可以选择一个升级: redisson-3.11.3、redisson-3.11.2、redisson-3.11.1、redisson-3.11.0、redisson-3.10.7、redisson-3.10.6、redisson-3.10.5、redisson-3.10.4、redisson-3.10.3、redisson-3.10.2、redisson-3.10.1、redisson-2.15.2、redisson-2.15.1

GitHub 加速计划 / re / redisson
23.06 K
5.31 K
下载
Redisson - Easy Redis Java client with features of In-Memory Data Grid. Sync/Async/RxJava/Reactive API. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, RPC, local cache ...
最近提交(Master分支:24 天前 )
15bd94ed - 1 个月前
d220f2a8 - 1 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐