From 0db2ecab5b6118f333e7c3993a2a6b9d613b5ac0 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Wed, 23 Aug 2023 11:42:26 +0300 Subject: [PATCH] Fixed - false slots added,slots removed messages in Redis Cluster. #4338 --- .../org/redisson/cluster/ClusterConnectionManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java index 2590d76fb..1082580f7 100644 --- a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java +++ b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java @@ -499,7 +499,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { continue; } - MasterSlaveEntry entry = getEntry(currentPart.slots().nextSetBit(0)); + MasterSlaveEntry entry = getEntry(currentPart.getSlotRanges().iterator().next().getStartSlot()); // should be invoked first in order to remove stale failedSlaveAddresses CompletableFuture> addedSlavesFuture = addRemoveSlaves(entry, currentPart, newPart); CompletableFuture f = addedSlavesFuture.thenCompose(addedSlaves -> { @@ -717,13 +717,14 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { // https://github.com/redisson/redisson/issues/3635 Map nodeEntries = clusterLastPartitions.stream().collect(Collectors.toMap(p -> p.getNodeId(), - p -> getEntry(p.slots().nextSetBit(0)))); + p -> getEntry(p.getSlotRanges().iterator().next().getStartSlot()))); Set changedSlots = new HashSet<>(); for (ClusterPartition currentPartition : clusterLastPartitions) { String nodeId = currentPartition.getNodeId(); for (ClusterPartition newPartition : newPartitions) { - if (!Objects.equals(nodeId, newPartition.getNodeId())) { + if (!Objects.equals(nodeId, newPartition.getNodeId()) + || newPartition.getSlotRanges().equals(currentPartition.getSlotRanges())) { continue; }