1.问题发现(定时任务中发现jedis的rpop方法,会使线程长时间挂起)
jstack展示的堆栈信息
查阅发现一个jdk的问题
SocketInputStream.socketRead0 can hang even with soTimeout set
Bug Database_socketRead0
2.官方在16年以做出修改
3.comments
The customer tested with the attached native tests. Both the poll (which mimics the JDK’s behaviour) and the socket timeout option (which does not) reproduced the issue. The underlying cause appears to be related to the customers infrastructure, and not a JDK problem.
客户使用附带的本机测试进行了测试。轮询(模仿JDK的行为)和套接字超时选项(没有)都再现了这个问题。根本原因似乎与客户的基础架构有关,而不是JDK问题。
4.说是客户端问题,检查jedis版本
检查发现jedis版本仍然是2.5.2,最新已经是4.0.1了,遂做版本更新,并重新放回执行定时任务,做长期观测。
5.问题梳理
#1.jdk的SocketInputStream.socketRead0方法导致线程长期挂起,官方修复;
#2.由于socker是通信基础,客户端在对此开发时可能未对上述问题做处理,历史影响;
#3.许多基于socket开发的客户端,如jedis,旧的版本会出现,期待新版本对此问题做出修复;
#4.代码测试、长期观测;