alibaba / jetcache

JetCache is a Java cache framework.
Apache License 2.0
5.03k stars 1.05k forks source link

jetcache使用lettuce连接集群,在集群主节点故障后无法识别恢复后的拓扑 #815

Closed anic closed 12 months ago

anic commented 12 months ago

jetcache使用lettuce连接redis集群(3主3从)

jetcache:
  areaInCacheName: false
  hidePackages: com.alibaba
  local:
    default:
      expireAfterWriteInMillis: 100000
      keyConvertor: fastjson
      limit: 100
      type: caffeine
  remote:
    default:
      uri:
        - redis://${currentIp}:6371
        - redis://${currentIp}:6372
        - redis://${currentIp}:6373
        - redis://${currentIp}:6374
        - redis://${currentIp}:6375
        - redis://${currentIp}:6376
      type: redis.lettuce
      keyConvertor: fastjson
      poolConfig:
        maxIdle: 20
        maxTotal: 50
        minIdle: 5
      valueDecoder: kryo
      valueEncoder: kryo

io.lettuce.core.RedisException: Currently not connected. Commands are rejected. at io.lettuce.core.protocol.DefaultEndpoint.validateWrite(DefaultEndpoint.java:308) ~[lettuce-core-6.1.10.RELEASE.jar:6.1.10.RELEASE] at io.lettuce.core.protocol.DefaultEndpoint.write(DefaultEndpoint.java:180) ~[lettuce-core-6.1.10.RELEASE.jar:6.1.10.RELEASE] at io.lettuce.core.cluster.ClusterDistributionChannelWriter.writeCommand(ClusterDistributionChannelWriter.java:238) ~[lettuce-core-6.1.10.RELEASE.jar:6.1.10.RELEASE] at io.lettuce.core.cluster.ClusterDistributionChannelWriter.writeCommand(ClusterDistributionChannelWriter.java:224) ~[lettuce-core-6.1.10.RELEASE.jar:6.1.10.RELEASE] at io.lettuce.core.cluster.ClusterDistributionChannelWriter.doWrite(ClusterDistributionChannelWriter.java:173) ~[lettuce-core-6.1.10.RELEASE.jar:6.1.10.RELEASE] at io.lettuce.core.cluster.ClusterDistributionChannelWriter.write(ClusterDistributionChannelWriter.java:103) ~[lettuce-core-6.1.10.RELEASE.jar:6.1.10.RELEASE] at io.lettuce.core.RedisChannelHandler.dispatch(RedisChannelHandler.java:191) ~[lettuce-core-6.1.10.RELEASE.jar:6.1.10.RELEASE] at io.lettuce.core.cluster.StatefulRedisClusterConnectionImpl.dispatch(StatefulRedisClusterConnectionImpl.java:215) ~[lettuce-core-6.1.10.RELEASE.jar:6.1.10.RELEASE] at io.lettuce.core.AbstractRedisAsyncCommands.dispatch(AbstractRedisAsyncCommands.java:627) ~[lettuce-core-6.1.10.RELEASE.jar:6.1.10.RELEASE] at io.lettuce.core.AbstractRedisAsyncCommands.psetex(AbstractRedisAsyncCommands.java:1317) ~[lettuce-core-6.1.10.RELEASE.jar:6.1.10.RELEASE] at com.alicp.jetcache.redis.lettuce.RedisLettuceCache.do_PUT(RedisLettuceCache.java:99) ~[jetcache-redis-lettuce-2.5.13.jar:na] at com.alicp.jetcache.AbstractCache.PUT(AbstractCache.java:235) ~[jetcache-core-2.5.13.jar:na] at com.alicp.jetcache.Cache.PUT(Cache.java:363) ~[jetcache-core-2.5.13.jar:na] at com.alicp.jetcache.Cache.put(Cache.java:74) ~[jetcache-core-2.5.13.jar:na] at com.alicp.jetcache.AbstractCache.lambda$computeIfAbsentImpl$2(AbstractCache.java:146) ~[jetcache-core-2.5.13.jar:na] at com.alicp.jetcache.AbstractCache.computeIfAbsentImpl(AbstractCache.java:156) ~[jetcache-core-2.5.13.jar:na] at com.alicp.jetcache.AbstractCache.computeIfAbsent(AbstractCache.java:112) ~[jetcache-core-2.5.13.jar:na] at com.alicp.jetcache.Cache.computeIfAbsent(Cache.java:311) ~[jetcache-core-2.5.13.jar:na] at com.alicp.jetcache.SimpleProxyCache.computeIfAbsent(SimpleProxyCache.java:93) ~[jetcache-core-2.5.13.jar:na] at com.alicp.jetcache.anno.method.CacheHandler.invokeWithCached(CacheHandler.java:245) ~[jetcache-anno-2.5.13.jar:na] at com.alicp.jetcache.anno.method.CacheHandler.doInvoke(CacheHandler.java:92) ~[jetcache-anno-2.5.13.jar:na] at com.alicp.jetcache.anno.method.CacheHandler.invoke(CacheHandler.java:84) ~[jetcache-anno-2.5.13.jar:na] at com.alicp.jetcache.anno.aop.JetCacheInterceptor.invoke(JetCacheInterceptor.java:74) ~[jetcache-anno-2.5.13.jar:na] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.27.jar:5.3.27]


此时需要重启应用才能恢复

根据lettuce官方说明,lettuce已经实现故障后更新拓扑图的功能,见 https://github.com/spring-projects/spring-boot/issues/15630

建议jetcache提供相关的特性支持
areyouok commented 12 months ago

具体要怎么改?现在应该已经有了,60s刷新

见RedisLettuceAutoConfiguration类

image

anic commented 12 months ago

具体要怎么改?现在应该已经有了,60s刷新

见RedisLettuceAutoConfiguration类

image

这个逻辑是符合要求的,是我配置没有增加mode=cluster以及版本不对,升级后配置好就ok了,谢谢