CLUSTERDOWN error
The cluster can't serve the command because a hash slot has no working node.
A Redis cluster returns this error when it can't serve your command. The message has two versions:
CLUSTERDOWN Hash slot not served
CLUSTERDOWN The cluster is down
Hash slot not servedmeans that no node serves the key's hash slot. This happens when some slots were never assigned to a node, for example, in a cluster you haven't finished setting up.The cluster is downmeans that the cluster is in a failed state. By default, a cluster stops serving commands when any hash slot has no working node. For example, this happens when a primary node fails and has no replica to take its place.
In redis-py, this error is ClusterDownError: The cluster is down or ClusterDownError: Hash slot not served.
Example
After a primary with no replica fails, the other nodes stop serving commands, even for their own keys:
> GET foo
(error) CLUSTERDOWN The cluster is down
How to fix it
- Check the state of the cluster with
CLUSTER INFO.cluster_state:failmeans the cluster is down.cluster_slots_assignedshows how many of the 16384 slots have a node. - Find the failed nodes with
CLUSTER NODES. A failed node hasfailin its flags. - Bring the failed node back, or move its slots to working nodes. If slots were never assigned, assign them.
redis-cli --cluster createassigns all the slots when it creates a cluster.
To keep the cluster working when a primary fails, give each primary at least one replica. A replica then takes its primary's place.
Two settings change what a cluster does when some slots have no working node:
cluster-require-full-coverage nolets nodes keep serving the slots that still have a working node.cluster-allow-reads-when-down yeslets nodes serve reads while the cluster is in a failed state. Writes then getCLUSTERDOWN The cluster is down and only accepts read commands.