Assigns new hash slots to a node.
CLUSTER
ADDSLOTS
slot
[slot…]
This command is useful in order to modify a node’s view of the cluster configuration. Specifically it assigns a set of hash slots to the node receiving the command. If the command is successful, the node will map the specified hash slots to itself, and will start broadcasting the new configuration.
However note that:
importing
, this state gets
cleared once the node assigns the (previously unbound) slot to
itself.Simple string
reply: OK
if the command was successful. Otherwise an
error is returned.
O(N) where N is the total number of hash slot arguments
@admin @dangerous @slow
For example the following command assigns slots 1 2 3 to the node receiving the command:
> CLUSTER ADDSLOTS 1 2 3
OK
However trying to execute it again results into an error since the slots are already assigned:
> CLUSTER ADDSLOTS 1 2 3
ERR Slot 1 is already busy
This command only works in cluster mode and is useful in the following Valkey Cluster operations:
cluster ADDSLOTS
is used in order to
initially setup primary nodes splitting the available hash slots among
them.Note that once a node assigns a set of slots to itself, it will start propagating this information in heartbeat packet headers. However the other nodes will accept the information only if they have the slot as not already bound with another node, or if the configuration epoch of the node advertising the new hash slot, is greater than the node currently listed in the table.
This means that this command should be used with care only by
applications orchestrating Valkey Cluster, like valkey-cli
,
and the command if used out of the right context can leave the cluster
in a wrong state or cause data loss.
ASKING, CLUSTER, CLUSTER ADDSLOTSRANGE, CLUSTER BUMPEPOCH, CLUSTER COUNT-FAILURE-REPORTS, CLUSTER COUNTKEYSINSLOT, CLUSTER DELSLOTS, CLUSTER DELSLOTSRANGE, CLUSTER FAILOVER, CLUSTER FLUSHSLOTS, CLUSTER FORGET, CLUSTER GETKEYSINSLOT, CLUSTER HELP, CLUSTER INFO, CLUSTER KEYSLOT, CLUSTER LINKS, CLUSTER MEET, CLUSTER MYID, CLUSTER MYSHARDID, CLUSTER NODES, CLUSTER REPLICAS, CLUSTER REPLICATE, CLUSTER RESET, CLUSTER SAVECONFIG, CLUSTER SET-CONFIG-EPOCH, CLUSTER SETSLOT, CLUSTER SHARDS, CLUSTER SLOT-STATS, CLUSTER SLOTS, READONLY, READWRITE.