redistemplate.executePilined可能导致sockettimeout

k5hmc34c  于 2021-06-08  发布在  Redis
关注(0)|答案(1)|浏览(865)

这是我的密码:

redisTemplate.executePipelined(new SessionCallback<Object>() {
    @Override
    public Object execute(RedisOperations redisOperations) throws DataAccessException {
        redisTemplate.opsForSet().add(e, businessCode);
        return null;
    }
});

内部代码“redistemplate.opsforset().add(e,businesscode);”正在使用一个连接吗
谢谢你的回答
补充堆栈错误信息:

org.springframework.data.redis.RedisConnectionFailureException: java.net.SocketTimeoutException: Read timed out; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out
    at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:67)
    at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:41)
    at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:37)
    at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:37)
    at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:241)
    at org.springframework.data.redis.connection.jedis.JedisConnection.zRange(JedisConnection.java:2348)
    at org.springframework.data.redis.connection.DefaultStringRedisConnection.zRange(DefaultStringRedisConnection.java:1058)
    at org.springframework.data.redis.core.DefaultZSetOperations$5.doInRedis(DefaultZSetOperations.java:101)
    at org.springframework.data.redis.core.DefaultZSetOperations$5.doInRedis(DefaultZSetOperations.java:98)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:207)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:169)
    at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:91)
    at org.springframework.data.redis.core.DefaultZSetOperations.range(DefaultZSetOperations.java:98)
    at com.*.mshop.reach.service.impl.ReachServiceImpl.query(ReachServiceImpl.java:178)
    at com.*.mshop.reach.service.impl.ReachServiceImpl$$FastClassBySpringCGLIB$$633d23e1.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:667)
    at com.*.mshop.reach.service.impl.ReachServiceImpl$$EnhancerBySpringCGLIB$$486aa953.query(<generated>)
    at com.*.mshop.facade.controller.ReachControllerImpl.query$original$1525E0bP(ReachControllerImpl.java:174)
    at com.*.mshop.facade.controller.ReachControllerImpl.query$original$1525E0bP$accessor$dcQnJrPQ(ReachControllerImpl.java)
    at com.*.mshop.facade.controller.ReachControllerImpl$auxiliary$jZ0njKo2.call(Unknown Source)
    at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:86)
    at com.*.mshop.facade.controller.ReachControllerImpl.query(ReachControllerImpl.java)
    at com.*.mshop.facade.controller.ReachControllerImpl.queryCommodity$original$1525E0bP(ReachControllerImpl.java:203)
    at com.*.mshop.facade.controller.ReachControllerImpl.queryCommodity$original$1525E0bP$accessor$dcQnJrPQ(ReachControllerImpl.java)
    at com.*.mshop.facade.controller.ReachControllerImpl$auxiliary$NkOmWqfY.call(Unknown Source)
    at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:86)
    at com.*.mshop.facade.controller.ReachControllerImpl.queryCommodity(ReachControllerImpl.java)
    at com.*.mshop.facade.controller.ReachControllerImpl$$FastClassBySpringCGLIB$$c8f1c1b6.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

在此异常之前调用executePilined,大约1分钟,无法获得redis连接。
redis连接池配置:

spring.redis.pool.max-active = 2000
spring.redis.pool.max-wait = 5000
spring.redis.pool.max-idle = 200
spring.redis.pool.min-idle = 10
spring.redis.timeout = 0
s4n0splo

s4n0splo1#

redis管道对绝地和莴苣有不同的实现。
在绝地武士中,管道将阻塞1个连接并用同一个连接发送所有管道命令(bio)
在莴苣中,管道使用nettynio作为网络连接工具。因此,在客户端执行管道时,它不会阻塞连接(通常使用单连接)。当管道执行(发送到redis)时,它将从netty中选择1个连接。
这两个库对管道命令使用相同的连接,因为它们将在单个网络请求中一起发送所有命令。

相关问题