codingapi / codingapi/tx-lcn

TM连接redis-cluster报错

Open
#459 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
4.2k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

- [ ] I have searched the [issues](https://github.com/codingapi/tx-lcn/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);
}
}

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.