| 
 | 1 | +---  | 
 | 2 | +acl_categories:  | 
 | 3 | +- '@admin'  | 
 | 4 | +- '@slow'  | 
 | 5 | +- '@dangerous'  | 
 | 6 | +arguments:  | 
 | 7 | +- arguments:  | 
 | 8 | +  - arguments:  | 
 | 9 | +    - display_text: start-slot  | 
 | 10 | +      name: start-slot  | 
 | 11 | +      type: integer  | 
 | 12 | +    - display_text: end-slot  | 
 | 13 | +      name: end-slot  | 
 | 14 | +      type: integer  | 
 | 15 | +    multiple: true  | 
 | 16 | +    name: import  | 
 | 17 | +    token: IMPORT  | 
 | 18 | +    type: block  | 
 | 19 | +  - arguments:  | 
 | 20 | +    - display_text: task-id  | 
 | 21 | +      name: task-id  | 
 | 22 | +      token: ID  | 
 | 23 | +      type: string  | 
 | 24 | +    - display_text: all  | 
 | 25 | +      name: all  | 
 | 26 | +      token: ALL  | 
 | 27 | +      type: pure-token  | 
 | 28 | +    name: cancel  | 
 | 29 | +    token: CANCEL  | 
 | 30 | +    type: oneof  | 
 | 31 | +  - arguments:  | 
 | 32 | +    - display_text: task-id  | 
 | 33 | +      name: task-id  | 
 | 34 | +      optional: true  | 
 | 35 | +      token: ID  | 
 | 36 | +      type: string  | 
 | 37 | +    - display_text: all  | 
 | 38 | +      name: all  | 
 | 39 | +      optional: true  | 
 | 40 | +      token: ALL  | 
 | 41 | +      type: pure-token  | 
 | 42 | +    name: status  | 
 | 43 | +    token: STATUS  | 
 | 44 | +    type: block  | 
 | 45 | +  name: subcommand  | 
 | 46 | +  type: oneof  | 
 | 47 | +arity: -4  | 
 | 48 | +categories:  | 
 | 49 | +- docs  | 
 | 50 | +- develop  | 
 | 51 | +- stack  | 
 | 52 | +- oss  | 
 | 53 | +- rs  | 
 | 54 | +- rc  | 
 | 55 | +- oss  | 
 | 56 | +- kubernetes  | 
 | 57 | +- clients  | 
 | 58 | +command_flags:  | 
 | 59 | +- admin  | 
 | 60 | +- stale  | 
 | 61 | +- no_async_loading  | 
 | 62 | +complexity: O(N) where N is the total number of the slots between the start slot and  | 
 | 63 | +  end slot arguments.  | 
 | 64 | +description: Start, monitor, and cancel atomic slot migration tasks.  | 
 | 65 | +group: cluster  | 
 | 66 | +hidden: false  | 
 | 67 | +linkTitle: CLUSTER MIGRATION  | 
 | 68 | +since: 8.4.0  | 
 | 69 | +summary: Start, monitor, and cancel atomic slot migration tasks.  | 
 | 70 | +syntax_fmt: "CLUSTER MIGRATION <IMPORT\_start-slot end-slot [start-slot end-slot\n\  | 
 | 71 | +  \  ...] | CANCEL\_<ID\_task-id | ALL> | STATUS\_[ID\_task-id] [ALL]>"  | 
 | 72 | +syntax_str: ''  | 
 | 73 | +title: CLUSTER MIGRATION  | 
 | 74 | +---  | 
 | 75 | + | 
 | 76 | +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.  | 
 | 77 | + | 
 | 78 | +## Required arguments  | 
 | 79 | + | 
 | 80 | +<details open><summary><code>subcommand</code></summary>  | 
 | 81 | + | 
 | 82 | +The subcommand specifies the operation to perform:  | 
 | 83 | + | 
 | 84 | +- `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 can be used to monitor the status of the task.  | 
 | 85 | + | 
 | 86 | +- `CANCEL [ID <task-id> | ALL]`: Cancels an ongoing migration task by its ID or cancels all tasks if `ALL` is 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.  | 
 | 87 | + | 
 | 88 | +- `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. If no arguments are provided, returns status for all tasks.  | 
 | 89 | + | 
 | 90 | +</details>  | 
 | 91 | + | 
 | 92 | +## Examples  | 
 | 93 | + | 
 | 94 | +Import slots 0-1000 and 2000-3000 to the current node:  | 
 | 95 | + | 
 | 96 | +```bash  | 
 | 97 | +CLUSTER MIGRATION IMPORT 0 1000 2000 3000  | 
 | 98 | +```  | 
 | 99 | + | 
 | 100 | +Check the status of all migration tasks:  | 
 | 101 | + | 
 | 102 | +```bash  | 
 | 103 | +CLUSTER MIGRATION STATUS ALL  | 
 | 104 | +```  | 
 | 105 | + | 
 | 106 | +Check the status of a specific migration task:  | 
 | 107 | + | 
 | 108 | +```bash  | 
 | 109 | +CLUSTER MIGRATION STATUS ID 24cf41718b20f7f05901743dffc40bc9b15db339  | 
 | 110 | +```  | 
 | 111 | + | 
 | 112 | +Cancel a specific migration task:  | 
 | 113 | + | 
 | 114 | +```bash  | 
 | 115 | +CLUSTER MIGRATION CANCEL ID 24cf41718b20f7f05901743dffc40bc9b15db339  | 
 | 116 | +```  | 
 | 117 | + | 
 | 118 | +Cancel all migration tasks:  | 
 | 119 | + | 
 | 120 | +```bash  | 
 | 121 | +CLUSTER MIGRATION CANCEL ALL  | 
 | 122 | +```  | 
 | 123 | + | 
 | 124 | +## Return information  | 
 | 125 | + | 
 | 126 | +{{< multitabs id="return-info"  | 
 | 127 | +    tab1="RESP2"  | 
 | 128 | +    tab2="RESP3" >}}  | 
 | 129 | + | 
 | 130 | +For the `IMPORT` subcommand:  | 
 | 131 | +[Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): task ID on success, or error message on failure.  | 
 | 132 | + | 
 | 133 | +For the `CANCEL` subcommand:  | 
 | 134 | +[Integer reply](../../develop/reference/protocol-spec#integers): number of cancelled tasks.  | 
 | 135 | + | 
 | 136 | +For the `STATUS` subcommand:  | 
 | 137 | +[Array reply](../../develop/reference/protocol-spec#arrays): a list of migration task details. Each task is represented as an array containing field-value pairs:  | 
 | 138 | +- `id`: Task identifier  | 
 | 139 | +- `slots`: Slot range being migrated  | 
 | 140 | +- `source`: Source node ID  | 
 | 141 | +- `dest`: Destination node ID  | 
 | 142 | +- `operation`: Operation type (typically "migrate")  | 
 | 143 | +- `state`: Current state ("completed", "in_progress", etc.)  | 
 | 144 | +- `last_error`: Last error message (empty if none)  | 
 | 145 | +- `retries`: Number of retry attempts  | 
 | 146 | +- `create_time`: Task creation timestamp  | 
 | 147 | +- `start_time`: Task start timestamp  | 
 | 148 | +- `end_time`: Task completion timestamp (if completed)  | 
 | 149 | +- `write_pause_ms`: Write pause duration in milliseconds  | 
 | 150 | + | 
 | 151 | +-tab-sep-  | 
 | 152 | + | 
 | 153 | +For the `IMPORT` subcommand:  | 
 | 154 | +[Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): task ID on success, or error message on failure.  | 
 | 155 | + | 
 | 156 | +For the `CANCEL` subcommand:  | 
 | 157 | +[Integer reply](../../develop/reference/protocol-spec#integers): number of cancelled tasks.  | 
 | 158 | + | 
 | 159 | +For the `STATUS` subcommand:  | 
 | 160 | +[Array reply](../../develop/reference/protocol-spec#arrays): a list of migration task details. Each task is represented as an array containing field-value pairs:  | 
 | 161 | +- `id`: Task identifier  | 
 | 162 | +- `slots`: Slot range being migrated  | 
 | 163 | +- `source`: Source node ID  | 
 | 164 | +- `dest`: Destination node ID  | 
 | 165 | +- `operation`: Operation type (typically "migrate")  | 
 | 166 | +- `state`: Current state ("completed", "in_progress", etc.)  | 
 | 167 | +- `last_error`: Last error message (empty if none)  | 
 | 168 | +- `retries`: Number of retry attempts  | 
 | 169 | +- `create_time`: Task creation timestamp  | 
 | 170 | +- `start_time`: Task start timestamp  | 
 | 171 | +- `end_time`: Task completion timestamp (if completed)  | 
 | 172 | +- `write_pause_ms`: Write pause duration in milliseconds  | 
 | 173 | + | 
 | 174 | +{{< /multitabs >}}  | 
 | 175 | + | 
 | 176 | +## Notes  | 
 | 177 | + | 
 | 178 | +- The atomic slot migration feature is available starting from Redis 8.4.0.  | 
 | 179 | +- Migration tasks are tracked in memory and the number of archived tasks is controlled by the `cluster-slot-migration-max-archived-tasks` configuration (default: 32).  | 
 | 180 | +- During migration, the source node may pause writes briefly to hand off slot ownership. The duration is controlled by `cluster-slot-migration-write-pause-timeout` (default: 10 seconds).  | 
 | 181 | +- The handoff threshold is controlled by `cluster-slot-migration-handoff-max-lag-bytes` (default: 1MB).  | 
 | 182 | +- Cancelling a task on the source node does not automatically stop the migration on the destination node.  | 
 | 183 | +- In `CLUSTER MIGRATION STATUS` output, the "state" field will show `completed` for successful operations.  | 
 | 184 | +- Tasks with empty "last_error" fields indicate no errors occurred during the migration process.  | 
 | 185 | + | 
 | 186 | +## Key visibility during migration  | 
 | 187 | + | 
 | 188 | +During atomic slot migration operations, certain keys may be filtered out from the following commands while importing or trimming is in progress:  | 
 | 189 | + | 
 | 190 | +- [`KEYS`]({{< relref "/commands/keys" >}})  | 
 | 191 | +- [`SCAN`]({{< relref "/commands/scan" >}})  | 
 | 192 | +- [`RANDOMKEY`]({{< relref "/commands/randomkey" >}})  | 
 | 193 | +- [`CLUSTER GETKEYSINSLOT`]({{< relref "/commands/cluster-getkeysinslot" >}})  | 
 | 194 | +- [`DBSIZE`]({{< relref "/commands/dbsize" >}})  | 
 | 195 | +- [`CLUSTER COUNTKEYSINSLOT`]({{< relref "/commands/cluster-countkeysinslot" >}})  | 
 | 196 | + | 
 | 197 | +The [`INFO KEYSPACE`]({{< relref "/commands/info" >}}) command will continue to reflect the actual number of keys, including those being migrated.  | 
 | 198 | + | 
 | 199 | +## Related configuration  | 
 | 200 | + | 
 | 201 | +- `cluster-slot-migration-max-archived-tasks`: Maximum number of archived ASM tasks kept in memory for `CLUSTER MIGRATION STATUS ALL` output (default: 32, hidden config)  | 
 | 202 | +- `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)  | 
 | 203 | +- `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)  | 
 | 204 | +- `cluster-slot-migration-sync-buffer-drain-timeout`: Timeout for sync buffer drainage during ASM. Uses the maximum of this configurable timeout and a dynamic timeout based on slot snapshot application time (multiplied by 2 for conservatism) to handle cases where synchronization gap remains above acceptable limits (default: 60 seconds, hidden config)  | 
 | 205 | + | 
 | 206 | +## RDB format changes  | 
 | 207 | + | 
 | 208 | +A new auxiliary field `cluster-asm-task` has been added to the RDB format to support atomic slot migration. When an import operation begins, the master propagates an internal command through the replication stream, allowing replicas to recognize that an ASM operation is in progress. This enables replicas to trigger relevant module events so that modules can adapt their behavior, such as filtering out unowned keys from read-only requests during ASM operations.  | 
0 commit comments