For example: In a cluster made of two nodes A and B, key foo reside in the hash slot of node A, and you subscribe "keyevent@0:expired" channel through a client connected to B. you won't receive foo key's expire event.

Environment about the Bug:

Redis Version: latest(or else share the same problem I guess) Redis Client: original command line client redis-cli redis.conf file: the minimal cluster setting according to the official "Redis Cluster tutorial" and the only extra setting of [notify-keyspace-events "Exe" ]

Step to Reproduce the Bug

  1. Open two redis-cli (with -c option) to connect to a redis cluster. Say, clientA connect to master A, clientB connect to master B.
  2. On clientB type the command: subscribe __keyevent@0__:expired 3.On clientA, set a key on A: set foo 123 (assume foo's hash is mapped to node A, and you don't get redirected to another node). Then set a expire time on foo: expire foo 2
  3. 2 seconds passed, clientB didn't get a sound.
  4. However, if "foo" is a key whose hash is mapped to B, then the expected meesage appears on clientB.

Comment From: antirez

Hello. I'm not sure we are able to provide non-local events in Redis Cluster. This would require to broadcast the events cluster-wide, which is quite bandwidth intensive... Isn't it better that the client just subscribes to all the master nodes instead, merging all the received events? However one problem with this is that from time to time it should check the cluster configuration to make sure to connect to other masters added during the live of the cluster.

Comment From: Calabor-Hoc

@antirez Very grateful to your timely reply and sorry to mistake this feature as a BUG. Because the PubSub channel message got broadcast cluster-wide so I thought the keyevent message on channel keyevent@** is also supposed to be broadcast. Your work around is good, and I just havn't actually do it for worry about the overhead of so many connections. And lose any one of the connection can lose a message, since, you know, Redis cannot preserve a message for a subscriber during its disconnection.

Thank you very much!

Comment From: wanseanpark

I have the ’somequestion‘,too. thanks for your answering.

Comment From: ssthom

@antirez We are running into the same problem. We are using spring-data-redis. Do you know how we could configure the client to subscribe to all of the master nodes?

Comment From: axelpale

@antirez Here is a doc improvement proposal. Should the local-only behaviour of notifications be somehow mentioned in the documentation Redis Keyspace Notifications? I propose the following paragraph after the subtitle "Timing of expired events":

Behaviour in Redis Cluster

Where Pub/Sub messages are generally sent across the cluster, the keyspace notifications are only sent locally. Broadcasting such events cluster-wide could become very bandwidth intensive. However, to simulate cluster-wide behaviour, clients can subscribe to all the master nodes and merge the received events. In this approach the clients should check the cluster configuration from time to time to make sure to connect to other masters added in possible reconfiguration.

END

This piece of documentation clarifies how the notifications behave in a cluster setup and offers readers a sound workaround.

Comment From: itamarhaber

Closing this given https://github.com/redis/redis-doc/pull/1367.