Redis Cross Slot error

In a cluster topology, the keyspace is divided into hash slots. Different nodes will hold a subset of hash slots.

Multiple keys operations, transactions, or Lua scripts involving multiple keys are allowed only if all the keys involved are in hash slots belonging to the same node.

Redis Cluster implements all the single key commands available in the non-distributed version of Redis. Commands performing complex multi-key operations like Set type unions or intersections are implemented as well as long as the keys all belong to the same node.

You can force the keys to belong to the same node by using Hash Tags


ERR CROSSSLOT Keys in request don't hash to the same slot

As the error message suggests, only if all of the keys belong to same slot will the operation succeed. Otherwise, you will see this failure message. This error would be seen even though both/all slots belongs to the same node. The check is very strict and, as per the code, all keys should hash to same slot.

Tags:

Redis