Skip to content

Commit 61f5390

Browse files
committed
[GROW-2938] prevent get_node_from_slot from failing due to concurrent cluster slots refresh
1 parent b773789 commit 61f5390

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

redis/cluster.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,10 @@ def get_node_from_slot(self, slot, read_from_replicas=False, server_type=None):
14161416
# randomly choose one of the replicas
14171417
node_idx = random.randint(1, len(self.slots_cache[slot]) - 1)
14181418

1419-
return self.slots_cache[slot][node_idx]
1419+
try:
1420+
return self.slots_cache[slot][node_idx]
1421+
except IndexError:
1422+
return self.slots_cache[slot][0]
14201423

14211424
def get_nodes_by_server_type(self, server_type):
14221425
"""

0 commit comments

Comments
 (0)