# CLUSTER CANCELSLOTMIGRATIONS

> Cancel every atomic slot migration the receiving node is moving out, leaving the slots where they are.

URL: https://docs.hotkv.com/commands/cluster-cancelslotmigrations/

```
CLUSTER CANCELSLOTMIGRATIONS
```

- Group: Cluster
- Complexity: O(N) where N is the number of migrations in progress
- HotKV Cloud: not available
- On-Premise: no license needed

`CLUSTER CANCELSLOTMIGRATIONS` stops every atomic slot migration that the
receiving node is exporting, which are the ones started with
[`CLUSTER MIGRATESLOTS`](https://docs.hotkv.com/commands/cluster-migrateslots/index.md) or requested by a
target with [`CLUSTER MIGRATION IMPORT`](https://docs.hotkv.com/commands/cluster-migration/index.md). The
slots stay with this node and keep serving. The target deletes the copy it had
received.

Send it to the source. It only affects migrations still in progress: a
migration that has finished moved the slots, and cancelling cannot move them
back (start a new migration from the new owner for that). The node reports each
cancelled migration as `cancelled` in
[`CLUSTER GETSLOTMIGRATIONS`](https://docs.hotkv.com/commands/cluster-getslotmigrations/index.md), and the
target reports it as `failed`, with the message `Connection lost to source.`

A task that was started on the target with `CLUSTER MIGRATION IMPORT` is not
over when its export is cancelled: the target keeps retrying the import. Cancel such a task on the target with
[`CLUSTER MIGRATION CANCEL`](https://docs.hotkv.com/commands/cluster-migration/index.md).

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Migrations cancelled | Simple string `OK` | Simple string `OK` |
| No migration of this node is in progress | Error `ERR No migrations ongoing` | Same |
| Cluster mode is off | Error `ERR This instance has cluster support disabled` | Same |

## Examples

With nothing running, then with a migration in progress.

```
127.0.0.1:7000> CLUSTER CANCELSLOTMIGRATIONS
(error) ERR No migrations ongoing
127.0.0.1:7000> CLUSTER MIGRATESLOTS SLOTSRANGE 150 199 NODE 49a04a859cbe2f18b168fdff41f4f2346045f9e3
OK
127.0.0.1:7000> CLUSTER CANCELSLOTMIGRATIONS
OK
127.0.0.1:7000> CLUSTER COUNTKEYSINSLOT 150
(integer) 8
127.0.0.1:7001> CLUSTER COUNTKEYSINSLOT 150
(integer) 0
```

## Compatibility

The same command and the same error text as Valkey 9. Redis 8 has no such
command; it cancels with `CLUSTER MIGRATION CANCEL`.

## See also

[CLUSTER MIGRATESLOTS](https://docs.hotkv.com/commands/cluster-migrateslots/index.md),
[CLUSTER GETSLOTMIGRATIONS](https://docs.hotkv.com/commands/cluster-getslotmigrations/index.md),
[CLUSTER MIGRATION](https://docs.hotkv.com/commands/cluster-migration/index.md),
[Scaling a cluster](https://docs.hotkv.com/clustering/scaling/index.md)