CLUSTER MIGRATION
CLUSTER MIGRATION <IMPORT start-slot end-slot [start-slot end-slot ...] | CANCEL <ID task-id | ALL> | STATUS <ID task-id | ALL>
- Available since:
- Redis Open Source 8.4.0
- Time complexity:
- O(N) where N is the total number of the slots between the start slot and end slot arguments.
- ACL categories:
-
@admin,@slow,@dangerous,
The CLUSTER MIGRATION command provides atomic slot migration functionality for Redis Cluster. This command allows you to import slots from other nodes, monitor the progress of migration tasks, and cancel ongoing migrations.
Required arguments
subcommand
The subcommand specifies the operation to perform:
-
IMPORT <start-slot> <end-slot> [<start-slot> <end-slot> ...]: Executes on the destination master. Accepts multiple slot ranges and triggers atomic migration for the specified ranges. Returns a task ID that you can use to monitor the status of the task. -
CANCEL <ID <task-id> | ALL>: Cancels an ongoing migration task by its ID or cancels all tasks ifALLis specified. Note: Cancelling a task on the source node does not stop the migration on the destination node, which will continue retrying until it is also cancelled there. -
STATUS [ID <task-id> | ALL]: Displays the status of current and completed atomic slot migration tasks. If a specific task ID is provided, it returns detailed information for that task only. IfALLis specified, it returns the status of all ongoing and completed tasks.
Examples
Import slots 0-1000 and 2000-3000 to the current node:
CLUSTER MIGRATION IMPORT 0 1000 2000 3000
Check the status of all migration tasks:
CLUSTER MIGRATION STATUS ALL
Check the status of a specific migration task:
CLUSTER MIGRATION STATUS ID 24cf41718b20f7f05901743dffc40bc9b15db339
Cancel a specific migration task:
CLUSTER MIGRATION CANCEL ID 24cf41718b20f7f05901743dffc40bc9b15db339
Cancel all migration tasks:
CLUSTER MIGRATION CANCEL ALL
Redis Software and Redis Cloud compatibility
| Redis Enterprise |
Redis Cloud |
Notes |
|---|---|---|
| ❌ Standard |
❌ Standard |
Return information
For the IMPORT subcommand:
Bulk string reply: task ID on success, or error message on failure.
For the CANCEL subcommand:
Integer reply: number of cancelled tasks.
For the STATUS subcommand:
Array reply: a list of migration task details. Each task is represented as an array containing field-value pairs:
id: Task identifierslots: Slot range being imported or migratedsource: Source node IDdest: Destination node IDoperation: Operation type ("import" or "migrate")state: Current state ("completed", "in_progress", etc.)last_error: Last error message (empty if none)retries: Number of retry attemptscreate_time: Task creation timestampstart_time: Task start timestampend_time: Task completion timestamp (if completed)write_pause_ms: Write pause duration in milliseconds
Notes
- The atomic slot migration feature is available starting from Redis 8.4.0.
- Cancelling a task on the source node does not automatically stop the migration on the destination node.
- In
CLUSTER MIGRATION STATUSoutput, the "state" field will showcompletedfor successful operations. - Tasks with empty "last_error" fields indicate no errors occurred during the migration process.
Key visibility during migration
During atomic slot migration operations, keys in unowned slotsmay be filtered out from the following commands while importing or trimming is in progress:
The INFO KEYSPACE command will continue to reflect the actual number of keys, including those being imported.
Related configuration
cluster-slot-migration-handoff-max-lag-bytes: After slot snapshot completion, if remaining replication stream size falls below this threshold, the source node pauses writes to hand off slot ownership. Higher values trigger handoff earlier but may cause longer write pauses. Lower values result in shorter write pauses but may be harder to reach with steady incoming writes (default: 1MB).cluster-slot-migration-write-pause-timeout: Maximum duration that the source node pauses writes during ASM handoff. If the destination fails to take over slots within this timeout, the source assumes migration failed and resumes writes (default: 10 seconds).