加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程 > 正文

记一次找因Redis行使不妥导致应用卡死Bug的进程

发布时间:2019-10-12 09:02:21 所属栏目:编程 来源:小木
导读:起首说下题目征象:内网sandbox情形API一连1周呈现应用卡死,全部api无相应征象 刚开始当测试诉苦情形相应慢的时辰 ,我们重启一下应用,应用规复正常,于是没做处理赏罚。可是其后题目呈现频率越来越频仍,越来越多的同事开始诉苦,于是感受代码也许有题目,

随意找一个线程查察堆内存

  1. thread -428 

记一次找因Redis行使不妥导致应用卡死Bug的进程

这是能确认就是api一向转圈的题目,就是这个redis获取毗连的代码导致的,

解读这段内存代码  全部线程都在等 @53e5504e这个工具开释锁。于是jstack 全局搜了一把53e5504e ,没有找到这个工具地址线程。

自此。题目缘故起因能确定是 redis毗连获取的题目。可是什么缘故起因造成获取不到毗连的还不能确定

再次执行 arthas 的thread -b (thread -b, 找出当前阻塞其他线程的线程)

记一次找因Redis行使不妥导致应用卡死Bug的进程

没有功效。这边和想的纷歧样,应该是能找到一个阻塞线程的,于是看了下这个呼吁的文档,发明有下面的一句话

记一次找因Redis行使不妥导致应用卡死Bug的进程

好吧,我们恰恰是后者。。。。

再次清算下思绪。这次修改redis pool 设置,将获取毗连超时时刻配置为2s,然后等题目再次复现时调查应用最后正常时干过什么。

添加一下设置

  1. JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();  
  2. .......  
  3. JedisPoolConfig config = new JedisPoolConfig();  
  4. config.setMaxWaitMillis(2000);  
  5. .......  
  6. jedisConnectionFactory.afterPropertiesSet(); 

重启处事,守候。。。。

又过一天,再次复现

ssh 处事器,搜查tomcat accesslog ,发明大量api 哀求呈现500,

  1. org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource fr 
  2.  om the pool  
  3.     at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:140)  
  4.     at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:229)  
  5.     at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:57)  
  6.     at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:128)  
  7.     at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:91)  
  8.     at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:78)  
  9.     at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:177)  
  10.     at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:152)  
  11.     at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:85)  
  12.     at org.springframework.data.redis.core.DefaultHashOperations.get(DefaultHashOperations.java:48) 

找到源头第一次呈现500处所,

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读