# 错误：槽位1234不属于此节点

- **ID:** `redis/redis-cluster-slot-ownership-error`
- **领域:** redis
- **类别:** runtime_error
- **错误码:** `ERR`
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

客户端向不拥有请求哈希槽位的Redis集群节点发送请求，通常由于集群配置过时或槽位迁移未完成。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| redis 6.0 | active | — | — |
| redis 6.2 | active | — | — |
| redis 7.0 | active | — | — |
| redis 7.2 | active | — | — |

## 解决方案

1. ```
   Use `CLUSTER SETSLOT 1234 IMPORTING source-node-id` on the destination node and `CLUSTER SETSLOT 1234 MIGRATING destination-node-id` on the source, then run `redis-cli --cluster reshard <host>:<port> --from <source-id> --to <dest-id> --slots 1234` to migrate the slot.
   ```
2. ```
   Update client cluster configuration by calling `CLUSTER SLOTS` on a known node and reconfiguring the client's slot map, e.g., in redis-py: `r.cluster('slots')` to refresh.
   ```
3. ```
   If slot is unassigned, assign it to a node: `CLUSTER ADDSLOTS 1234` on the target node, then verify with `CLUSTER INFO`.
   ```

## 无效尝试

- **Manually adding the slot to the node using CLUSTER ADDSLOTS** — Adding slots without proper migration can cause data loss or inconsistency; CLUSTER ADDSLOTS is only safe for unassigned slots. (95% 失败率)
- **Restarting the node** — Restart does not update cluster topology; the node still does not own the slot unless a proper migration occurs. (90% 失败率)
- **Flushing all data on the node** — Deleting data does not reassign slots; the node remains without the slot, and data loss occurs. (98% 失败率)
