codingapi / codingapi/tx-lcn

TM连接redis-cluster报错

Offen
#459 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
4.2k
Forks
1.4k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

- [ ] 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);
}
}

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start at com.codingapi.txlcn.tm.core.storage.redis.RedisStorage.refreshMachines, especially the transaction calls and the discard path shown in the stack trace. Reproduce the failure with the supplied Redis 5.0.3 cluster configuration and inspect the Spring Data Redis/Lettuce interaction. Done means TM can refresh machines without the RedisSystemException or ClassCastException.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java, redis, spring
Bereich
backend, databases
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.