Skip to content

[BUG] Blocking reads don't work on Redis Cluster replica nodes #7877

@o948

Description

@o948

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:

redis/src/cluster.c

Lines 5856 to 5862 in 3945a32

clusterNode *node = server.cluster->slots[slot];
/* We send an error and unblock the client if:
* 1) The slot is unassigned, emitting a cluster down error.
* 2) The slot is not handled by this node, nor being imported. */
if (node != myself &&
server.cluster->importing_slots_from[slot] == NULL)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions