随意找一个线程查看堆内存
- thread -428

这是能确认就是api一直转圈的问题,就是这个redis获取连接的代码导致的,
解读这段内存代码 所有线程都在等 @53e5504e这个对象释放锁。于是jstack 全局搜了一把53e5504e ,没有找到这个对象所在线程。
自此。问题原因能确定是 redis连接获取的问题。但是什么原因造成获取不到连接的还不能确定
再次执行 arthas 的thread -b (thread -b, 找出当前阻塞其他线程的线程)

没有结果。这边和想的不一样,应该是能找到一个阻塞线程的,于是看了下这个命令的文档,发现有下面的一句话

好吧,我们刚好是后者。。。。
再次整理下思路。这次修改redis pool 配置,将获取连接超时时间设置为2s,然后等问题再次复现时观察应用最后正常时干过什么。
添加一下配置
- JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
- .......
- JedisPoolConfig config = new JedisPoolConfig();
- config.setMaxWaitMillis(2000);
- .......
- jedisConnectionFactory.afterPropertiesSet();
重启服务,等待。。。。
又过一天,再次复现
ssh 服务器,检查tomcat accesslog ,发现大量api 请求出现500,
- org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource fr
- om the pool
- at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:140)
- at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:229)
- at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:57)
- at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:128)
- at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:91)
- at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:78)
- at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:177)
- at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:152)
- at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:85)
- at org.springframework.data.redis.core.DefaultHashOperations.get(DefaultHashOperations.java:48)
找到源头第一次出现500地方, (编辑:威海站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|