【问题标题】:Cannot determine a partition for slot无法确定插槽的分区
【发布时间】:2022-12-17 06:43:39
【问题描述】:

在某些 redis 操作期间,我面临 PartitionSelectorException。

Caused by: io.lettuce.core.cluster.PartitionSelectorException: Cannot determine a partition for slot 12004. at io.lettuce.core.cluster.PooledClusterConnectionProvider.getWriteConnection(PooledClusterConnectionProvider.java:164) at io.lettuce.core.cluster.PooledClusterConnectionProvider.getConnectionAsync(PooledClusterConnectionProvider.java:149) at io.lettuce.core.cluster.ClusterDistributionChannelWriter.doWrite(ClusterDistributionChannelWriter.java:170) at io.lettuce.core.cluster.ClusterDistributionChannelWriter.write(ClusterDistributionChannelWriter.java:103) at io.lettuce.core.RedisChannelHandler.dispatch(RedisChannelHandler.java:218) at io.lettuce.core.cluster.StatefulRedisClusterConnectionImpl.dispatch(StatefulRedisClusterConnectionImpl.java:216) at io.lettuce.core.AbstractRedisAsyncCommands.dispatch(AbstractRedisAsyncCommands.java:676) at io.lettuce.core.AbstractRedisAsyncCommands.get(AbstractRedisAsyncCommands.java:960) at sun.reflect.GeneratedMethodAccessor425.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at io.lettuce.core.cluster.ClusterFutureSyncInvocationHandler.handleInvocation(ClusterFutureSyncInvocationHandler.java:122) at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80) at com.sun.proxy.$Proxy254.get(Unknown Source) at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.get(LettuceStringCommands.java:68)

代码配置

ClusterTopologyRefreshOptions topologyRefreshOptions = ClusterTopologyRefreshOptions.builder() .enablePeriodicRefresh(Duration.ofSeconds(30)) .enableAllAdaptiveRefreshTriggers() .build();

ClientOptions options = ClusterClientOptions.builder() .disconnectedBehavior(ClientOptions.DisconnectedBehavior.REJECT_COMMANDS) .autoReconnect(true) .topologyRefreshOptions(topologyRefreshOptions) .build();

GenericObjectPoolConfig genericObjectPoolConfig = new GenericObjectPoolConfig(); genericObjectPoolConfig.setMinIdle(8); genericObjectPoolConfig.setMaxIdle(16); genericObjectPoolConfig.setMaxTotal(16); LettucePoolingClientConfiguration.builder() .poolConfig(genericObjectPoolConfig) .clientOptions(options) .clientResources(clientResources) .build();

环境

生菜版本:[6.1.5.RELEASE]

Redis版本:[5.0.6]

碎片:6

节点数:12

分析

Redis 集群运行良好,所有指标都符合预期。

那么,你能给我一些建议吗?谢谢!

【问题讨论】:

    标签: java redis redis-cluster lettuce


    【解决方案1】:

    我有同样的问题。我通过删除并重新启动我的 Kubernetes pod 解决了这个问题。重启 Spring Boot 也可能会奏效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-11
      • 1970-01-01
      • 1970-01-01
      • 2014-05-02
      • 1970-01-01
      • 2020-04-18
      • 1970-01-01
      • 2020-06-29
      相关资源
      最近更新 更多