Skip to content

Commit d21f2bf

Browse files
authored
[GROW-3598] make initialize to loop through replica nodes per cluster slots row (#17)
1 parent 16f87bf commit d21f2bf

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

redis/cluster.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,25 +1561,25 @@ def initialize(self):
15611561
# add this node to the nodes cache
15621562
tmp_nodes_cache[target_node.name] = target_node
15631563

1564+
target_replica_nodes = []
1565+
for replica_node in slot[3:]:
1566+
host = str_if_bytes(replica_node[0])
1567+
port = int(replica_node[1])
1568+
host, port = self.remap_host_port(host, port)
1569+
1570+
target_replica_node = self._get_or_create_cluster_node(
1571+
host, port, REPLICA, tmp_nodes_cache
1572+
)
1573+
target_replica_nodes.append(target_replica_node)
1574+
# add this node to the nodes cache
1575+
tmp_nodes_cache[target_replica_node.name] = target_replica_node
1576+
15641577
for i in range(int(slot[0]), int(slot[1]) + 1):
15651578
if i not in tmp_slots:
15661579
tmp_slots[i] = []
15671580
tmp_slots[i].append(target_node)
1568-
replica_nodes = [slot[j] for j in range(3, len(slot))]
1569-
1570-
for replica_node in replica_nodes:
1571-
host = str_if_bytes(replica_node[0])
1572-
port = replica_node[1]
1573-
host, port = self.remap_host_port(host, port)
1574-
1575-
target_replica_node = self._get_or_create_cluster_node(
1576-
host, port, REPLICA, tmp_nodes_cache
1577-
)
1581+
for target_replica_node in target_replica_nodes:
15781582
tmp_slots[i].append(target_replica_node)
1579-
# add this node to the nodes cache
1580-
tmp_nodes_cache[
1581-
target_replica_node.name
1582-
] = target_replica_node
15831583
else:
15841584
# Validate that 2 nodes want to use the same slot cache
15851585
# setup

0 commit comments

Comments
 (0)