TM连接redis-cluster报错
- Ngôn ngữ chính
- Java
- Star
- 4.2k
- Fork
- 1.4k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
- [ ] 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);
}
}
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu tại com.codingapi.txlcn.tm.core.storage.redis.RedisStorage.refreshMachines, đặc biệt là các lệnh gọi transaction và discard path được hiển thị trong stack trace. Tái hiện lỗi với cấu hình Redis 5.0.3 cluster được cung cấp và kiểm tra tương tác giữa Spring Data Redis và Lettuce. Hoàn tất khi TM có thể refresh machines mà không gặp RedisSystemException hoặc ClassCastException.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java, redis, spring
- Lĩnh vực
- backend, databases
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100