gpt4 book ai didi

redis - 单分片 Redis Cluster 怎么会出现 CROSSLOT 错误?

转载 作者:IT王子 更新时间:2023-10-29 06:12:56 27 4
gpt4 key购买 nike

我不明白只有一个分片的 Redis 集群怎么会导致 CROSSLOT 错误。根据文档,当您发出影响多个键的命令时,会发生此错误,这些键并不都位于同一哈希槽(即分片环境中的节点)中。鉴于单个分片只有一个插槽; 0-16383 - 以及所有数据 - 这怎么会发生?

在我的例子中,我有一个分片和一个只读副本(从属)。

我使用散列标签规避了这个问题,如下所述:https://redis.io/topics/cluster-spec - 然而这并没有回答问题。

这是 CLUSTER NODES 的输出:

e51c5f84e60116be3cb9d6734fc0c4deb1fde4c4 172.31.6.149:6379@1122 slave c07ed67b7df1a9d4475702c944a43ad38c6954ba 0 1531143884198 1 connected
c07ed67b7df1a9d4475702c944a43ad38c6954ba 172.31.21.122:6379@1122 myself,master - 0 0 1 connected 0-16383

我可以像这样重现错误:

telnet 172.31.21.122 6379

SETEX redis-test-1 3600 whatever
+OK
SETEX redis-test-2 3600 whatever
+OK

KEYS redis-test*
*2
$12
redis-test-2
$12
redis-test-1

DEL redis-test-1 redis-test-2
-CROSSSLOT Keys in request don't hash to the same slot

最佳答案

这也让我很困惑。 Redis code要求 key 散列到同一个插槽(而不是同一个节点),我不明白为什么会这样,因为 cluster specification说以下(强调我的):

Redis Cluster implements all the single key commands available in the non-distributed version of Redis. Commands performing complex multi-key operations like Set type unions or intersections are implemented as well as long as the keys all belong to the same node.

我在 GH 上开了一个问题:https://github.com/antirez/redis/issues/5118

关于redis - 单分片 Redis Cluster 怎么会出现 CROSSLOT 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51248853/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com