Describe the bug
Blocking reads on Redis Cluster replica nodes (in readonly mode) always get redirected to a master node.
To reproduce
Connect to a replica node, go into a readonly mode, do a blocking read, e.g.:
127.0.0.1:6381> CONNECT 127.0.0.1 6385
127.0.0.1:6385> READONLY
OK
127.0.0.1:6385> XREAD STREAMS k 0
(nil)
127.0.0.1:6385> XREAD BLOCK 100 STREAMS k 0
-> Redirected to slot [7629] located at 127.0.0.1:6381
(nil)
127.0.0.1:6381>
Expected behavior
According to documentation of READONLY:
When the connection is in readonly mode, the cluster will send a redirection to the client only if the operation involves keys not served by the replica's master node.
blocking reads should not get redirected to a master node.
Additional information
IIUC the clusterRedirectBlockedClientIfNeeded does not handle the case when the blocking read is on a replica node:
https://github.com/redis/redis/blob/3945a321779a0be52e556aa11babb3fe15883a78/src/cluster.c#L5856-L5862
Comment From: oranagra
@o948 thanks for reporting, please have a look at the fix in #7881 and let me know what you think.
Comment From: o948
Thanks for a quick fix, looks good to me. Do you know whether this fix is important enough to go to the next minor 5.0 release?
Comment From: oranagra
it's relatively safe, so it can get there, but i'm not sure if / when we'll make another 5.0 release. we are likely to do that only if there's some critical issue that's found. i'll mark the PR for followup.