Skip to content

Commit 1ea657e

Browse files
committed
[GROW-2938] do not reset redis_connection on an error
1 parent d95d8a2 commit 1ea657e

File tree

2 files changed

+0
-41
lines changed

2 files changed

+0
-41
lines changed

redis/cluster.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,8 +1143,6 @@ def _execute_command(self, target_node, *args, **kwargs):
11431143
# Remove the failed node from the startup nodes before we try
11441144
# to reinitialize the cluster
11451145
self.nodes_manager.startup_nodes.pop(target_node.name, None)
1146-
# Reset the cluster node's connection
1147-
target_node.redis_connection = None
11481146
self.nodes_manager.initialize()
11491147
raise e
11501148
except MovedError as e:

tests/test_cluster.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -788,45 +788,6 @@ def test_not_require_full_coverage_cluster_down_error(self, r):
788788
else:
789789
raise e
790790

791-
def test_timeout_error_topology_refresh_reuse_connections(self, r):
792-
"""
793-
By mucking TIMEOUT errors, we'll force the cluster topology to be reinitialized,
794-
and then ensure that only the impacted connection is replaced
795-
"""
796-
node = r.get_node_from_key("key")
797-
r.set("key", "value")
798-
node_conn_origin = {}
799-
for n in r.get_nodes():
800-
node_conn_origin[n.name] = n.redis_connection
801-
real_func = r.get_redis_connection(node).parse_response
802-
803-
class counter:
804-
def __init__(self, val=0):
805-
self.val = int(val)
806-
807-
count = counter(0)
808-
with patch.object(Redis, "parse_response") as parse_response:
809-
810-
def moved_redirect_effect(connection, *args, **options):
811-
# raise a timeout for 5 times so we'll need to reinitialize the topology
812-
if count.val == 4:
813-
parse_response.side_effect = real_func
814-
count.val += 1
815-
raise TimeoutError()
816-
817-
parse_response.side_effect = moved_redirect_effect
818-
assert r.get("key") == b"value"
819-
for node_name, conn in node_conn_origin.items():
820-
if node_name == node.name:
821-
# The old redis connection of the timed out node should have been
822-
# deleted and replaced
823-
assert conn != r.get_redis_connection(node)
824-
else:
825-
# other nodes' redis connection should have been reused during the
826-
# topology refresh
827-
cur_node = r.get_node(node_name=node_name)
828-
assert conn == r.get_redis_connection(cur_node)
829-
830791
def test_cluster_get_set_retry_object(self, request):
831792
retry = Retry(NoBackoff(), 2)
832793
r = _get_client(RedisCluster, request, retry=retry)

0 commit comments

Comments
 (0)