Skip to content

Commit d9b177d

Browse files
authored
Merge branch 'master' into ps_fix_timeseries_tests_test_against_rc2
2 parents 2eb3ef4 + 2053834 commit d9b177d

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

redis/asyncio/cluster.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def from_url(cls, url: str, **kwargs: Any) -> "RedisCluster":
229229
@deprecated_args(
230230
args_to_warn=["read_from_replicas"],
231231
reason="Please configure the 'load_balancing_strategy' instead",
232-
version="5.0.3",
232+
version="5.3.0",
233233
)
234234
def __init__(
235235
self,
@@ -808,10 +808,16 @@ async def _execute_command(
808808
# and try again with the new setup
809809
await self.aclose()
810810
raise
811-
except ClusterDownError:
811+
except (ClusterDownError, SlotNotCoveredError):
812812
# ClusterDownError can occur during a failover and to get
813813
# self-healed, we will try to reinitialize the cluster layout
814814
# and retry executing the command
815+
816+
# SlotNotCoveredError can occur when the cluster is not fully
817+
# initialized or can be temporary issue.
818+
# We will try to reinitialize the cluster topology
819+
# and retry executing the command
820+
815821
await self.aclose()
816822
await asyncio.sleep(0.25)
817823
raise

redis/asyncio/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ def can_get_connection(self) -> bool:
11331133
@deprecated_args(
11341134
args_to_warn=["*"],
11351135
reason="Use get_connection() without args instead",
1136-
version="5.0.3",
1136+
version="5.3.0",
11371137
)
11381138
async def get_connection(self, command_name=None, *keys, **options):
11391139
async with self._lock:
@@ -1306,7 +1306,7 @@ def __init__(
13061306
@deprecated_args(
13071307
args_to_warn=["*"],
13081308
reason="Use get_connection() without args instead",
1309-
version="5.0.3",
1309+
version="5.3.0",
13101310
)
13111311
async def get_connection(self, command_name=None, *keys, **options):
13121312
"""Gets a connection from the pool, blocking until one is available"""

redis/cluster.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def get_node_name(host: str, port: Union[str, int]) -> str:
5858
@deprecated_args(
5959
allowed_args=["redis_node"],
6060
reason="Use get_connection(redis_node) instead",
61-
version="5.0.3",
61+
version="5.3.0",
6262
)
6363
def get_connection(redis_node, *args, **options):
6464
return redis_node.connection or redis_node.connection_pool.get_connection()
@@ -410,7 +410,12 @@ class AbstractRedisCluster:
410410
list_keys_to_dict(["SCRIPT FLUSH"], lambda command, res: all(res.values())),
411411
)
412412

413-
ERRORS_ALLOW_RETRY = (ConnectionError, TimeoutError, ClusterDownError)
413+
ERRORS_ALLOW_RETRY = (
414+
ConnectionError,
415+
TimeoutError,
416+
ClusterDownError,
417+
SlotNotCoveredError,
418+
)
414419

415420
def replace_default_node(self, target_node: "ClusterNode" = None) -> None:
416421
"""Replace the default cluster node.
@@ -485,7 +490,7 @@ class initializer. In the case of conflicting arguments, querystring
485490
@deprecated_args(
486491
args_to_warn=["read_from_replicas"],
487492
reason="Please configure the 'load_balancing_strategy' instead",
488-
version="5.0.3",
493+
version="5.3.0",
489494
)
490495
def __init__(
491496
self,
@@ -1239,13 +1244,19 @@ def _execute_command(self, target_node, *args, **kwargs):
12391244
except AskError as e:
12401245
redirect_addr = get_node_name(host=e.host, port=e.port)
12411246
asking = True
1242-
except ClusterDownError as e:
1247+
except (ClusterDownError, SlotNotCoveredError):
12431248
# ClusterDownError can occur during a failover and to get
12441249
# self-healed, we will try to reinitialize the cluster layout
12451250
# and retry executing the command
1251+
1252+
# SlotNotCoveredError can occur when the cluster is not fully
1253+
# initialized or can be temporary issue.
1254+
# We will try to reinitialize the cluster topology
1255+
# and retry executing the command
1256+
12461257
time.sleep(0.25)
12471258
self.nodes_manager.initialize()
1248-
raise e
1259+
raise
12491260
except ResponseError:
12501261
raise
12511262
except Exception as e:
@@ -1482,7 +1493,7 @@ def _update_moved_slots(self):
14821493
"In case you need select some load balancing strategy "
14831494
"that will use replicas, please set it through 'load_balancing_strategy'"
14841495
),
1485-
version="5.0.3",
1496+
version="5.3.0",
14861497
)
14871498
def get_node_from_slot(
14881499
self,

redis/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ def _checkpid(self) -> None:
15021502
@deprecated_args(
15031503
args_to_warn=["*"],
15041504
reason="Use get_connection() without args instead",
1505-
version="5.0.3",
1505+
version="5.3.0",
15061506
)
15071507
def get_connection(self, command_name=None, *keys, **options) -> "Connection":
15081508
"Get a connection from the pool"
@@ -1730,7 +1730,7 @@ def make_connection(self):
17301730
@deprecated_args(
17311731
args_to_warn=["*"],
17321732
reason="Use get_connection() without args instead",
1733-
version="5.0.3",
1733+
version="5.3.0",
17341734
)
17351735
def get_connection(self, command_name=None, *keys, **options):
17361736
"""

0 commit comments

Comments
 (0)