apache / kvrocks

Apache Kvrocks is a distributed key value NoSQL database that uses RocksDB as storage engine and is compatible with Redis protocol.
https://kvrocks.apache.org/
Apache License 2.0
3.57k stars 468 forks source link

PubSub publish behaves differently with Redis in cluster mode #2157

Open jcy1001 opened 8 months ago

jcy1001 commented 8 months ago

Search before asking

Version

kvrocks2.7 pubsub测试了发现了个问题,在集群部署模式下 subscribe 后,publish 这个channel一个消息,无法消费到;这个在redis上面没有问题。我用monitor看到的现象是redis和kvrocks,sub和pub的server收到消息的node都是不一样,但kvrocks无法消费到,redis是ok的,

Minimal reproduce step

kvrocks2.7 pubsub测试了发现了个问题,在集群部署模式下 subscribe 后,publish 这个channel一个消息,无法消费到;这个在redis上面没有问题。我用monitor看到的现象是redis和kvrocks,sub和pub的server收到消息的node都是不一样,但kvrocks无法消费到,redis是ok的,

What did you expect to see?

the same with redis ,will consume this msg

What did you see instead?

can consume this msg

Anything Else?

No response

Are you willing to submit a PR?

git-hulk commented 8 months ago

@jcy1001 Which client you're using?

jcy1001 commented 8 months ago

@git-hulk I found redis7 has this code ,but kvrocks doesnot propagatetocluster

/ PUBLISH / void publishCommand(client *c) { if (server.sentinel_mode) { sentinelPublishCommand(c); return; }

int receivers = pubsubPublishMessageAndPropagateToCluster(c->argv[1],c->argv[2],0);
if (!server.cluster_enabled)
    forceCommandPropagation(c,PROPAGATE_REPL);
addReplyLongLong(c,receivers);

}

git-hulk commented 8 months ago

@jcy1001 Thanks for your investigation. So what you mean is PubSub behaves differently with Redis in cluster mode?

jcy1001 commented 8 months ago

@jcy1001 Thanks for your investigation. So what you mean is PubSub behaves differently with Redis in cluster mode?

是,在redis集群下面客户端可以收到通知, kvrocks下收不到通知,分析看了是redis集群模式下,有做cluster的扩散,kvrocks只能通知本shard下的客户端

git-hulk commented 8 months ago

@jcy1001 Got your point, thank you!