Open evbo opened 7 years ago
This issue appears more generic to me than just lrange, it looks like it applies to GET, and potentially every operation.
From what I can tell from looking at the code, although RedisCluster figures out the master and slaves for each slot, it then never pays any attention to the slaves list. It only evaluates masters when trying to find the right connection for a command.
So it would seem that putting any read replicas into the list of RedisServer you provide to RedisCluster is pointless. (Unless, maybe, one of them gets promoted to be a master? I'm not sure about that.)
Wait, if we put sharding aside, does it mean that the READ load is not distributed among all nodes and all GET queries are hitting the master? I was expecting WRITES to go only to master and READs to be distributed in a round robin fashion.
From what I can see in the code, any load is really not distributed to replicas, this is the place where it looks like it ignores all connections except for Master
:
https://github.com/etaty/rediscala/blob/master/src/main/scala/redis/RedisCluster.scala#L65
What is the protocol for telling rediscala to read from slaves and not master for an LRANGE operation?
Starting with Redis-cli, this can be accomplished on connecting to the slave and running:
READONLY
. Then, subsequentLRANGE
commands will read directly from the slave for that client connection.With Rediscala, I noticed that
lrange()
callsLrange()
which seems to have a boolean attribute that indicates it is not exclusively operating on master nodes:However, when restricting my
RedisServer
list to only slave nodes, I cannot get a connection to any of the slaves upon performing thelrange()
:the
lrange
fails with: