From 06ec4dfdbe5563e8504f60dc066b1aaa963ea46e Mon Sep 17 00:00:00 2001 From: Mayank Agarwal Date: Thu, 24 Aug 2023 20:04:51 +0530 Subject: [PATCH] Do not initialize cluster when cluster slots are empty for node --- rediscluster/nodemanager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rediscluster/nodemanager.py b/rediscluster/nodemanager.py index 9fe2b13a..c530f995 100644 --- a/rediscluster/nodemanager.py +++ b/rediscluster/nodemanager.py @@ -224,6 +224,9 @@ def initialize(self): try: r = self.get_redis_link(host=node["host"], port=node["port"], decode_responses=True) cluster_slots = r.execute_command("cluster", "slots") + if len(cluster_slots) == 0: + raise ResponseError('CLUSTERSLOTEMPTY') + startup_nodes_reachable = True except (ConnectionError, TimeoutError): continue @@ -232,7 +235,7 @@ def initialize(self): # Isn't a cluster connection, so it won't parse these exceptions automatically message = e.__str__() - if 'CLUSTERDOWN' in message or 'MASTERDOWN' in message: + if 'CLUSTERDOWN' in message or 'MASTERDOWN' in message or 'CLUSTERSLOTEMPTY' in message: continue else: raise RedisClusterException("ERROR sending 'cluster slots' command to redis server: {0}".format(node))