tx-lcn icon indicating copy to clipboard operation
tx-lcn copied to clipboard

TM连接redis-cluster报错

Open wanggd2019 opened this issue 6 years ago • 1 comments

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.

1. Bug Description

TM连接redis-cluster报错

2. Environment:

  • JDK version: JDK8
  • OS: centosOS 6.7
  • TX-LCN version: 5.0.2
  • Others: redis版本 5.0.3 redis-cluster配置: spring.redis.lettuce.pool.max-active=70 spring.redis.lettuce.pool.min-idle=10 spring.redis.lettuce.pool.max-idle=10 spring.redis.cluster.nodes=192.168.124.203:9001,192.168.124.203:9002,192.168.124.203:9003,192.168.124.203:9004,192.168.124.203:9005,192.168.124.203:9006 spring.redis.cluster.max-redirects=6 spring.redis.password=654310 spring.redis.timeout=60000ms

异常信息: org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy163 cannot be cast to io.lettuce.core.api.sync.RedisCommands at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:53) at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:43) at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:268) at org.springframework.data.redis.connection.lettuce.LettuceConnection.discard(LettuceConnection.java:623) at org.springframework.data.redis.connection.DefaultStringRedisConnection.discard(DefaultStringRedisConnection.java:273) at org.springframework.data.redis.core.RedisTemplate.lambda$discard$22(RedisTemplate.java:1019) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224) at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184) at org.springframework.data.redis.core.RedisTemplate.discard(RedisTemplate.java:1018) at com.codingapi.txlcn.tm.core.storage.redis.RedisStorage.refreshMachines(RedisStorage.java:269) at com.codingapi.txlcn.tm.support.service.impl.ManagerServiceImpl.refreshMachines(ManagerServiceImpl.java:86) at com.codingapi.txlcn.tm.txmsg.EnsureIdGenEngine.onTmReceivedHeart(EnsureIdGenEngine.java:61) at com.codingapi.txlcn.txmsg.netty.handler.RpcCmdDecoder.channelRead0(RpcCmdDecoder.java:61) at com.codingapi.txlcn.txmsg.netty.handler.RpcCmdDecoder.channelRead0(RpcCmdDecoder.java:40)

这段代码报错了 public void refreshMachines(long timeout, long... machines) { try { stringRedisTemplate.setEnableTransactionSupport(true); stringRedisTemplate.multi(); for (long mac : machines) { stringRedisTemplate.opsForValue().set(REDIS_MACHINE_ID_MAP_PREFIX + mac, "", timeout, TimeUnit.MILLISECONDS); } stringRedisTemplate.exec(); } catch (Throwable e) { stringRedisTemplate.discard(); } finally { stringRedisTemplate.setEnableTransactionSupport(false); } }

wanggd2019 avatar Nov 13 '19 03:11 wanggd2019

image 我修改了redis提交事务的写法,没报错了

DaleShay avatar Nov 18 '19 05:11 DaleShay