Skip to content

Commit 8197414

Browse files
committed
[GROW-3598] make initialize to loop through replica nodes per cluster slots row (#17)
1 parent bb3ae02 commit 8197414

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
@@ -1565,25 +1565,25 @@ def initialize(self):
15651565
# add this node to the nodes cache
15661566
tmp_nodes_cache[target_node.name] = target_node
15671567

1568+
target_replica_nodes = []
1569+
for replica_node in slot[3:]:
1570+
host = str_if_bytes(replica_node[0])
1571+
port = int(replica_node[1])
1572+
host, port = self.remap_host_port(host, port)
1573+
1574+
target_replica_node = self._get_or_create_cluster_node(
1575+
host, port, REPLICA, tmp_nodes_cache
1576+
)
1577+
target_replica_nodes.append(target_replica_node)
1578+
# add this node to the nodes cache
1579+
tmp_nodes_cache[target_replica_node.name] = target_replica_node
1580+
15681581
for i in range(int(slot[0]), int(slot[1]) + 1):
15691582
if i not in tmp_slots:
15701583
tmp_slots[i] = []
15711584
tmp_slots[i].append(target_node)
1572-
replica_nodes = [slot[j] for j in range(3, len(slot))]
1573-
1574-
for replica_node in replica_nodes:
1575-
host = str_if_bytes(replica_node[0])
1576-
port = replica_node[1]
1577-
host, port = self.remap_host_port(host, port)
1578-
1579-
target_replica_node = self._get_or_create_cluster_node(
1580-
host, port, REPLICA, tmp_nodes_cache
1581-
)
1585+
for target_replica_node in target_replica_nodes:
15821586
tmp_slots[i].append(target_replica_node)
1583-
# add this node to the nodes cache
1584-
tmp_nodes_cache[
1585-
target_replica_node.name
1586-
] = target_replica_node
15871587
else:
15881588
# Validate that 2 nodes want to use the same slot cache
15891589
# setup

0 commit comments

Comments
 (0)