redis连接被占完

来源:6-14 单点登录Redis存储Session及SessionId问题说明与集群实战-4

慕粉4192055

2018-01-04

老师您好,我在一次登录时报以下错,是redis连接被占完了吗,怎么会占完呢,它不会释放没用的连接吗,这怎么办呢,求解,谢谢老师。

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

at redis.clients.util.Pool.getResource(Pool.java:53) ~[jedis-2.6.0.jar:na]

at redis.clients.jedis.JedisPool.getResource(JedisPool.java:99) ~[jedis-2.6.0.jar:na]

at com.mmall.common.RedisPool.getJedis(RedisPool.java:42) ~[classes/:na]

at com.mmall.util.RedisPoolUtil.get(RedisPoolUtil.java:69) ~[classes/:na]

at com.mmall.controller.common.SessionExpireFilter.doFilter(SessionExpireFilter.java:32) [classes/:na]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.75]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.75]

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [spring-web-4.0.0.RELEASE.jar:4.0.0.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) [spring-web-4.0.0.RELEASE.jar:4.0.0.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) [catalina.jar:7.0.75]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) [catalina.jar:7.0.75]

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) [catalina.jar:7.0.75]

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110) [catalina.jar:7.0.75]

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) [catalina.jar:7.0.75]

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) [catalina.jar:7.0.75]

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:7.0.75]

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962) [catalina.jar:7.0.75]

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [catalina.jar:7.0.75]

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452) [catalina.jar:7.0.75]

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087) [tomcat-coyote.jar:7.0.75]

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) [tomcat-coyote.jar:7.0.75]

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) [tomcat-coyote.jar:7.0.75]

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_144]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_144]

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-coyote.jar:7.0.75]

at java.lang.Thread.run(Unknown Source) [na:1.8.0_144]

Caused by: java.util.NoSuchElementException: Unable to validate object

at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:497) ~[commons-pool2-2.0.jar:2.0]

at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:360) ~[commons-pool2-2.0.jar:2.0]

at redis.clients.util.Pool.getResource(Pool.java:51) ~[jedis-2.6.0.jar:na]

... 25 common frames omitted

http://img.mukewang.com/szimg/5a535e70000159df06001130.jpg

写回答

2回答

Geely

2018-01-09

你好,同学,我看了一下图片,左边是4个,右边是1个,一共才5个连接。。。看看你的连接池具体的参数配置。注意#Clients这个节点。

发上来,再继续比较一下,另外建议你启动的时候,在初始化redis连接池的时候debug,打开那个对象,看看内存,截图在发上来,一起来继续解决

0
0

Geely

2018-01-04

 你好,同学,进入redis的cli ,然后输入info 查看client连接数多少。发个截图上来我看一下。


0
1
慕粉4192055
老师,您好,我把截图编辑到上面的问题里了,您帮我看看,麻烦了。
2018-01-08
共1条回复

Java企业级电商项目架构 Tomcat集群与Redis分布式

Tomcat集群+Redis分布式+代码重构+源码原理解析

2685 学习 · 947 问题

查看课程