From d59afa8a0e80034510d6f4c4f8aeecbe0de87b34 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 10 Jun 2024 09:05:45 +0300 Subject: [PATCH] Fixed - last master node shouldn't be removed in cluster topology #5931 --- .../org/redisson/cluster/ClusterConnectionManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java index 5af92c2ea..6691e4076 100644 --- a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java +++ b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java @@ -709,7 +709,9 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { for (Integer slot : removedSlots) { ClusterPartition p = lastPartitions.remove(slot); - if (p != null && p.decReference() == 0) { + if (p != null + && p.decReference() == 0 + && lastUri2Partition.size() > 1) { lastUri2Partition.remove(p.getMasterAddress()); } removeEntry(slot); @@ -776,7 +778,8 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { removedSlots.stream().forEach(slot -> { if (lastPartitions.remove(slot, currentPartition)) { - if (currentPartition.decReference() == 0) { + if (currentPartition.decReference() == 0 + && lastUri2Partition.size() > 1) { lastUri2Partition.remove(currentPartition.getMasterAddress()); } removeEntry(slot, entry);