Skip to content

Commit fa17c77

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

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

redis/cluster.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,24 +1546,24 @@ def initialize(self):
15461546
# add this node to the nodes cache
15471547
tmp_nodes_cache[target_node.name] = target_node
15481548

1549+
target_replica_nodes = []
1550+
for replica_node in slot[3:]:
1551+
host = str_if_bytes(replica_node[0])
1552+
port = int(replica_node[1])
1553+
1554+
target_replica_node = self._get_or_create_cluster_node(
1555+
host, port, REPLICA, tmp_nodes_cache
1556+
)
1557+
target_replica_nodes.append(target_replica_node)
1558+
# add this node to the nodes cache
1559+
tmp_nodes_cache[target_replica_node.name] = target_replica_node
1560+
15491561
for i in range(int(slot[0]), int(slot[1]) + 1):
15501562
if i not in tmp_slots:
15511563
tmp_slots[i] = []
15521564
tmp_slots[i].append(target_node)
1553-
replica_nodes = [slot[j] for j in range(3, len(slot))]
1554-
1555-
for replica_node in replica_nodes:
1556-
host = str_if_bytes(replica_node[0])
1557-
port = replica_node[1]
1558-
1559-
target_replica_node = self._get_or_create_cluster_node(
1560-
host, port, REPLICA, tmp_nodes_cache
1561-
)
1565+
for target_replica_node in target_replica_nodes:
15621566
tmp_slots[i].append(target_replica_node)
1563-
# add this node to the nodes cache
1564-
tmp_nodes_cache[
1565-
target_replica_node.name
1566-
] = target_replica_node
15671567
else:
15681568
# Validate that 2 nodes want to use the same slot cache
15691569
# setup

0 commit comments

Comments
 (0)