java - redisson java客户端可以检测到集群拓扑中失败的主副本对的重启吗?
问题描述
我的 Spring 启动应用程序使用 redisson 3.3.0 来访问具有以下 YML 配置的 redis 集群拓扑:
redis:
cluster:
nodes: ${CLUSTER_HOST}:6379
read-mode: 'MASTER'
connections: 125
max_wait_millis: 10000
cluster-scan-interval: 1000
redis 集群设置为默认值(3 个节点,每个节点 1 个副本)。
我停止包含相同插槽(主副本对)的 2 个节点。然后,当我的应用程序尝试从这些插槽中读取密钥时,正如预期的那样,我得到了这个异常:
org.redisson.client.RedisConnectionException:
MasterConnectionPool no available Redis entries.
Disconnected hosts: [/${CLUSTER_HOST}:6379]
我想这是正确的,因为在使用 CLUSTER NODES 命令检查我的 redis 节点后,我可以看到 2 个节点已关闭,并且它们的插槽从集群中丢失。
问题是,当我再次启动节点时,我使用 CLUSTER INFO & CLUSTER NODES 检查集群是否已恢复。然而,当我的应用程序尝试再次从集群中读取数据时,我得到了这个 redisson 异常:
io.netty.util.concurrent.DefaultPromise: 151 - An
exception was thrown by org.redisson.command.CommandAsyncService$9.operationComplete()
java.lang.NullPointerException: null
at org.redisson.connection.MasterSlaveConnectionManager.connectionReadOp(MasterSlaveConnectionManager.java:731)
at org.redisson.command.CommandAsyncService.async(CommandAsyncService.java:501)
at org.redisson.command.CommandAsyncService.checkAttemptFuture(CommandAsyncService.java:751)
at org.redisson.command.CommandAsyncService.access$300(CommandAsyncService.java:80)
at org.redisson.command.CommandAsyncService$9.operationComplete(CommandAsyncService.java:610)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:512)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:505)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:484)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:425)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:122)
at org.redisson.misc.RedissonPromise.tryFailure(RedissonPromise.java:98)
at org.redisson.client.protocol.CommandData.tryFailure(CommandData.java:78)
at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:247)
at ...
每次我的应用程序尝试从/向这些特定插槽(即特定的主副本对)读取或写入时,我都会不断地得到它,尽管 redis 集群是好的。
Redisson 似乎无法检索特定主副本对的正确状态。
这可能是配置问题,还是默认行为?
解决方案
此问题已在 3.5.4 版本中修复。
推荐阅读
- javascript - 如何将此倒数计时器更改为分钟和秒?
- azure-active-directory - 获取powerbi embed token 403 Forbidden
- matplotlib - 有没有办法不显示使用 Matplotlib FuncAnimation 生成的 .PNG 图像?
- spring-boot - 如何在发现选项卡中获取日志中提供的字段的字段
- go - 为什么 unsafe.Sizeof 返回一个 uintptr?
- typescript - TypeScript 中是否可以使用编译时标记的数字?
- filtering - 服务器端过滤中的 Ag-grid setFilter
- java - 为 JDK 1.8 开发和测试注释处理器
- reactjs - 无法在 i18next 中使用来自 S3 buck 的 JSON
- java - 如何将不同大小的子数组存储到单个二维数组中