@@ -456,11 +456,12 @@ async def _determine_nodes(
456
456
return [random .choice (list (self .nodes_manager .nodes_cache .values ()))]
457
457
458
458
# get the node that holds the key's slot
459
- slot = await self ._determine_slot (* args )
460
- node = self .nodes_manager .get_node_from_slot (
461
- slot , self .read_from_replicas and command in READ_COMMANDS
462
- )
463
- return [node ]
459
+ return [
460
+ self .nodes_manager .get_node_from_slot (
461
+ await self ._determine_slot (* args ),
462
+ self .read_from_replicas and command in READ_COMMANDS ,
463
+ )
464
+ ]
464
465
465
466
async def _determine_slot (self , * args ) -> int :
466
467
command = args [0 ]
@@ -648,12 +649,11 @@ async def _execute_command(
648
649
except BusyLoadingError :
649
650
raise
650
651
except (ConnectionError , TimeoutError ):
651
- connection_error_retry_counter += 1
652
-
653
652
# Give the node 0.25 seconds to get back up and retry again
654
653
# with same node and configuration. After 5 attempts then try
655
654
# to reinitialize the cluster and see if the nodes
656
655
# configuration has changed or not
656
+ connection_error_retry_counter += 1
657
657
if connection_error_retry_counter < 5 :
658
658
await asyncio .sleep (0.25 )
659
659
else :
@@ -962,14 +962,6 @@ def get_nodes_by_server_type(self, server_type: str) -> List["ClusterNode"]:
962
962
if node .server_type == server_type
963
963
]
964
964
965
- def check_slots_coverage (self , slots_cache : Dict [int , List ["ClusterNode" ]]) -> bool :
966
- # Validate if all slots are covered or if we should try next
967
- # startup node
968
- for i in range (0 , REDIS_CLUSTER_HASH_SLOTS ):
969
- if i not in slots_cache :
970
- return False
971
- return True
972
-
973
965
async def initialize (self ) -> None :
974
966
self .read_load_balancer .reset ()
975
967
tmp_nodes_cache = {}
@@ -1078,10 +1070,13 @@ async def initialize(self) -> None:
1078
1070
f'slots cache: { ", " .join (disagreements )} '
1079
1071
)
1080
1072
1081
- fully_covered = self .check_slots_coverage (tmp_slots )
1073
+ # Validate if all slots are covered or if we should try next startup node
1074
+ fully_covered = True
1075
+ for i in range (0 , REDIS_CLUSTER_HASH_SLOTS ):
1076
+ if i not in tmp_slots :
1077
+ fully_covered = False
1078
+ break
1082
1079
if fully_covered :
1083
- # Don't need to continue to the next startup node if all
1084
- # slots are covered
1085
1080
break
1086
1081
1087
1082
if not startup_nodes_reachable :
0 commit comments