MOVED
communication
protocol_error
ai_generated
true
MOVED 12182 10.0.0.1:6379: Redis cluster redirect to different node
ID: communication/redis-cluster-moved-redirect
88%Fix Rate
86%Confidence
1Evidence
2023-09-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Redis 6.2 | active | — | — | — |
| Redis 7.0 | active | — | — | — |
| Redis 7.2 | active | — | — | — |
| ioredis 5.3 | active | — | — | — |
| redis-py 4.5 | active | — | — | — |
Root Cause
Redis cluster client sent a command to a node that does not own the key's hash slot, and the client is not using smart client-side routing or cluster-aware connection pooling.
generic中文
Redis 集群客户端将命令发送到不拥有该键哈希槽的节点,且客户端未使用智能客户端路由或集群感知的连接池。
Official Documentation
https://redis.io/docs/reference/cluster-spec/Workarounds
-
95% success Use a Redis cluster-aware client library that automatically handles MOVED redirections, e.g., ioredis Cluster: `new Redis.Cluster([{ host: '10.0.0.1', port: 6379 }])` which maintains a slot-to-node mapping.
Use a Redis cluster-aware client library that automatically handles MOVED redirections, e.g., ioredis Cluster: `new Redis.Cluster([{ host: '10.0.0.1', port: 6379 }])` which maintains a slot-to-node mapping. -
90% success Enable cluster mode in the client configuration with automatic slot refresh, e.g., in redis-py: `rediscluster.RedisCluster(startup_nodes=[{'host':'10.0.0.1','port':6379}], skip_full_coverage_check=True)`.
Enable cluster mode in the client configuration with automatic slot refresh, e.g., in redis-py: `rediscluster.RedisCluster(startup_nodes=[{'host':'10.0.0.1','port':6379}], skip_full_coverage_check=True)`. -
75% success If using a non-cluster-aware client, implement manual retry with slot calculation: compute the hash slot for the key using CRC16 modulo 16384, then connect to the correct node directly.
If using a non-cluster-aware client, implement manual retry with slot calculation: compute the hash slot for the key using CRC16 modulo 16384, then connect to the correct node directly.
中文步骤
使用支持 Redis 集群的客户端库自动处理 MOVED 重定向,例如 ioredis Cluster:`new Redis.Cluster([{ host: '10.0.0.1', port: 6379 }])`,它会维护槽到节点的映射。在客户端配置中启用集群模式并自动刷新槽信息,例如在 redis-py 中:`rediscluster.RedisCluster(startup_nodes=[{'host':'10.0.0.1','port':6379}], skip_full_coverage_check=True)`。如果使用非集群感知客户端,实现手动重试并计算槽位:使用 CRC16 对键取模 16384 计算哈希槽,然后直接连接到正确节点。
Dead Ends
Common approaches that don't work:
-
Manually redirect the client to the node IP in the MOVED error without updating the cluster topology
70% fail
The cluster topology may change again; manual redirection is not scalable and can cause further MOVED errors.
-
Disable cluster mode and connect to a single Redis instance
90% fail
Defeats the purpose of clustering; data may be incomplete or inconsistent across nodes.
-
Increase connection timeout in client configuration
85% fail
Timeout does not address the routing issue; MOVED is a protocol-level redirect, not a timeout.