CLUSTER SETSLOT

Since 1.1.0Cluster

Syntax

CLUSTER SETSLOT slot <IMPORTING|MIGRATING|NODE> node-id
CLUSTER SETSLOT slot STABLE

Sets the state of one slot on this node, for moving it by hand.

FormEffect
IMPORTING node-idOn the destination: the slot is coming from node-id. Commands for it are served after ASKING.
MIGRATING node-idOn the source: the slot is going to node-id. A command for a key that has already left is answered with ASK slot host:port.
NODE node-idnode-id owns the slot now. Sent to the destination, then to the source.
STABLEClears IMPORTING or MIGRATING.

Moving a slot by hand takes four steps, which redis-cli --cluster reshard drives:

  1. CLUSTER SETSLOT slot IMPORTING source-id on the destination;
  2. CLUSTER SETSLOT slot MIGRATING destination-id on the source;
  3. MIGRATE the slot's keys, in batches, from the source;
  4. CLUSTER SETSLOT slot NODE destination-id on the destination, then on the source.

A multi-key command whose keys are partly on each side meanwhile is answered with TRYAGAIN. CLUSTER MIGRATION moves slots in one command, without ASK.

A node that loses a slot to another master, by SETSLOT ... NODE or on the losing side of a partition, deletes the keys it holds in that slot.

Reply

  • OK.
  • ERR Unknown node.
  • ERR Unknown SETSLOT subcommand 'name'.

Examples

> CLUSTER SETSLOT 2780 IMPORTING b2744aeada9b56dd000f101f31447a33a15c9b08
OK

On the source, once the key has gone:

> GET user:7
(error) ASK 2780 127.0.0.1:17622