這輩子不想再看到jedisBrokenPipe!!
?文章來源地址http://www.zghlxwxcb.cn/news/detail-420418.html
測試環(huán)境運行16天后報錯信息:
?
本地調試時,130并發(fā)的報錯信息:
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并發(fā)沒問題。130并發(fā)就跪了。怎么想怎么奇怪,明明都關閉連接了,為啥還會無法獲取jedis連接,最后換了一種思路。不在當前切面類維護jedisPoolMap,而是用jedisConfig里的通用map,代碼見下圖:
?
最后扛住1000并發(fā)。10000會報錯連接超時,但是后續(xù)請求會完全正常得到響應。
?因為本地性能受限,所以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)文章來源:http://www.zghlxwxcb.cn/news/detail-420418.html
?
到了這里,關于記一次jedis連接池頑固問題排查與修改的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!