记一次网络丢包导致的redis缓存错误调查。
今天,线上环境和线下多人本地调试突然报redis错误不能访问。重启Redis、FlushDB、删除本机配置信息都试了,没效果。最后更换了另一个redis服务,仅仅好了一会儿又开始报相同的错误。排查发现,某一本地调试节点的共享缓存为空导致了本次的错误。
调试发现,在写入redis的时候,报错
SocketFailure (ReadSocketError/TimedOut, last-recv: 4) on xxx.xxx.xxx.xxx:xxx/Interactive, Idle/Faulted, last: HMSET, origin: ReadFromPipe, outstanding: 2, last-read: 26s ago, last-write: 0s ago, unanswered-write: 26s ago, keep-alive: 60s, state: ConnectedEstablished, mgr: 9 of 10 available, in: 0, in-pipe: 0, out-pipe: 0, last-heartbeat: 0s ago, last-mbeat: 0s ago, global: 0s ago, v: 2.5.61.22961
由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
使用 Redis GUI工具连接访问正常。
最后ping redis主机发现,该节点连接的网络丢包严重。切换到另一个网络后,redis可以正常写入,项目恢复正常。
注:项目上用到的redis连接工具为:StackExchange.Redis