首页 > 其他分享 >记一次jedis连接池顽固问题排查与修改

记一次jedis连接池顽固问题排查与修改

时间:2023-04-21 16:22:06浏览次数:42  
标签:java clients redis 排查 Connection jedis GeneralAuthorizationAspect 连接池

这辈子不想再看到jedisBrokenPipe!!

 

测试环境运行16天后报错信息:

05:42:32.629 [http-nio-8093-exec-2] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - [log,175] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Connection reset] with root cause java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) at java.net.SocketInputStream.read(SocketInputStream.java:141) at java.net.SocketInputStream.read(SocketInputStream.java:127) at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:196) at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:40) at redis.clients.jedis.Protocol.process(Protocol.java:151) at redis.clients.jedis.Protocol.read(Protocol.java:215) at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:340) at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:259) at redis.clients.jedis.Connection.getBulkReply(Connection.java:248) at redis.clients.jedis.Jedis.hget(Jedis.java:674) at com.chint.cdc.TenantAPI.getTenanatInfoWithNumberFromRedis(TenantAPI.java:224) at com.chint.cdc.TenantAPI.getInfoByNumber(TenantAPI.java:126) at com.chint.cdc.app.maintenance.authorization.GeneralAuth.GeneralAuthorizationAspect.getJedis(GeneralAuthorizationAspect.java:224) at com.chint.cdc.app.maintenance.authorization.GeneralAuth.GeneralAuthorizationAspect.around(GeneralAuthorizationAspect.java:131)

 

本地调试时,130并发的报错信息:

15:08:33.080 [http-nio-8093-exec-135] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - [log,175] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Software caused connection abort: socket write error] with root cause
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
at redis.clients.util.RedisOutputStream.flushBuffer(RedisOutputStream.java:52)
at redis.clients.util.RedisOutputStream.flush(RedisOutputStream.java:216)
at redis.clients.jedis.Connection.flush(Connection.java:331)
at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:257)
at redis.clients.jedis.Connection.getBulkReply(Connection.java:248)
at redis.clients.jedis.Jedis.hget(Jedis.java:674)
at com.chint.cdc.TenantAPI.getTenanatInfoWithNumberFromRedis(TenantAPI.java:224)
at com.chint.cdc.TenantAPI.getInfoByNumber(TenantAPI.java:126)
at com.chint.cdc.app.maintenance.authorization.GeneralAuth.GeneralAuthorizationAspect.getJedis(GeneralAuthorizationAspect.java:231)
at com.chint.cdc.app.maintenance.authorization.GeneralAuth.GeneralAuthorizationAspect.around(GeneralAuthorizationAspect.java:134)
at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

大佬一直说要记得释放连接,于是我改成以下写法:

但还是有问题,本地30并发没问题。130并发就跪了。怎么想怎么奇怪,明明都关闭连接了,为啥还会无法获取jedis连接,最后换了一种思路。不在当前切面类维护jedisPoolMap,而是用jedisConfig里的通用map,代码见下图:

 

最后扛住1000并发。10000会报错连接超时,但是后续请求会完全正常得到响应。

 因为本地性能受限,所以10s后报超时我觉得是正常的

15:56:42.773 [http-nio-8093-exec-450] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - [log,175] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool] with root cause
java.util.NoSuchElementException: Timeout waiting for idle object, borrowMaxWaitDuration=PT10S
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:312)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:223)
at redis.clients.util.Pool.getResource(Pool.java:49)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:226)
at com.chint.cdc.app.maintenance.authorization.GeneralAuth.GeneralAuthorizationAspect.getJedis(GeneralAuthorizationAspect.java:222)
at com.chint.cdc.app.maintenance.authorization.GeneralAuth.GeneralAuthorizationAspect.around(GeneralAuthorizationAspect.java:134)
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634)

 

标签:java,clients,redis,排查,Connection,jedis,GeneralAuthorizationAspect,连接池
From: https://www.cnblogs.com/geekheart/p/jedis2023.html

相关文章

  • 定制的视频监控球机接入EasyCVR后通道不显示的原因排查
    EasyCVR基于云边端智能协同,具有强大的数据接入、处理及分发能力,平台可支持多协议接入,包括市场主流标准协议与厂家私有协议及SDK,如:国标GB28181、RTMP、RTSP/Onvif、海康Ehome、海康SDK、宇视SDK等(具体见下图)。有用户反馈,将某品牌的定制款监控摄像头球机接入EasyCVR平台后,通道不显示......
  • TCP长连接的连接池、容量控制与心跳保活
    一、长连接与短连接TCP本身并没有长短连接的区别,长短与否,完全取决于我们怎么用它。短连接:每次通信时,创建Socket;一次通信结束,调用socket.close()。这就是一般意义上的短连接,短连接的好处是管理起来比较简单,存在的连接都是可用的连接,不需要额外的控制手段。长连接:每次通信完毕......
  • java.lang.OutOfMemoryError- unable to create new native thread 问题排查
    问题描述最近连续两天大约凌晨3点,线上服务开始异常,出现OOM报错。且服务所在的物理机只能ping通,但是无法登录。报错信息如下:ERROR04-1203:01:43,930[DefaultQuartzScheduler_Worker-3]JobRunShell[JobRunShell]:211JobthrewanunhandledException:java.lang.OutOfMemoryErr......
  • Spring Boot - Spring Boot 数据库连接池 Hikari 介绍
    SpringBoot数据库连接池Hikari介绍介绍TheHikariCPdesignaestheticisMinimalism.Inkeepingwiththesimpleisbetterorlessismoredesignphilosophy,someconfigurationaxisareintentionallyleftout.HikariCP奉行极简主义的设计美学。为了保持“越......
  • Jedis与RedisTemplate的区别
    Jedis与RedisTemplate的区别:Jedis是Redis官方推荐的、面向Java的操作Redis的客户端,可以用JedisPool来获得连接进行get、set、del等操作相对简单,而RedisTemplate是SpringDataRedis中对JedisApi的高度封装。SpringDataRedis相对于Jedis来说,可以方便地更换Redis的Java客户端,还......
  • flask蓝图、g对象、数据库连接池
    昨日回顾#1cbv使用写一个类继承MethodView,写get,post...类属性decorators=[auth,]可以加装饰器#2cbv执行流程1跟django流程一样2entpint作用路径别名,add_url_rule(view_func=Index.as_view('index'))3为什么entpint不传,是被路由装饰器装饰的函数......
  • 通过一个具体的例子,深入了解 SAP UI5 控件数据双向绑定的工作原理和问题排查方法试读
    笔者知识星球里有朋友提问:SAPUI5中的sap.m.select控件,在当前页面做任何操作时,都可以选中key值,但触发dialog之后,可以看到select框内的key值被清空,当关闭dialog后,再去选择key值,无任何反应,请问是select控件的问题还是dialog的问题又或者是odata写法有问题,谢谢!......
  • 问题故障排查
    今天在编写代码的时候发现一个问题,当我引入一个按钮控件的时候,发现页面就加载不了。后面通过排除法,发现代码中出现了循环应用。比如A组件,使用了mixinsBB中有个对话框又import了A,这个时候就会出现循环应用,页面工作不正常的情况。解决办法:不在页面使用import方法。......
  • 如何排查网络丢包问题
    如何排查网络丢包问题原文链接:https://mp.weixin.qq.com/s/k0s0kYSpCdF8SHBotuWCrg要明白一个知识点,首先要快速的对这个知识点建立一个概念模型,有了概念模型之后,再在这个模型上不断的去填充一些细节的东西,会有助于我们把握知识的本质。带宽是什么?带宽是网络被发送的能力,它会......
  • 高通5G平台(SDX55\SDX62\SDX65):ping包异常问题排查指南
    转自高通5G平台(SDX55\SDX62\SDX65):ping包异常问题排查指南-腾讯云开发者社区-腾讯云(tencent.com)高通5G平台:ping包异常问题排查指南 1.背景移动通信延续着每十年一代技术的发展规律,已历经1G、2G、3G、4G的发展。每一次代际跃迁,每一次技术进步,都极大地促进了产业升级和经......