Description
We enable ReadOnly=true
for the Redis cluster client. When a new slave node joins the cluster, the client can quickly detect the new slave node by updating the cluster states. Once a new node is detected, requests are immediately forwarded to that node. If the new slave node is still in the master-slave replication process and is waiting for the master node to send the RDB file, the result of the client's read operation will be nil.
Expected Behavior
A new slave node should not be added to the cluster state before completing master-slave replication.
Current Behavior
When a slave node joins the cluster, it is immediately added to the cluster state to receive client requests.
Possible Solution
To check if a node is in replication state when loading cluster state. Send the command info replication
to the slave node and add it into cluster state only when master_link_status
is up
.
Steps to Reproduce
- Setup a Redis cluster with at least one slave node for each shard.
- Fill a bulk of random data into the cluster. This is for extending the replication duration intentionally.
- Run a Redis cluster client (ReadOnly=true is enabled) to keep reading existing keys from the cluster.
- Add a slave node into the cluster.
- Check if the client reads nil values.