You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this is an actual issue or just me being dumb.
I have simple replication group setup with 1 master and 2 replicas (This is with the cluster-enabled config value set to false in the redis instance config). My goal is a have a setup where by default I am able to make READ command to the MASTER, but if it's down, the commands should be sent to the replicas. This becomes a bit tricky for the GEORADIUS command as it's considered a WRITE command by Redis.
Using the StatefulRedisMasterReplicationConnection I am issuing a custom GEORADIUS_RO command with ReadFrom set to MASTER_PREFERRED (there doesn't seem to be any in-built support for GEORADIUS_RO for non-cluster-enabled connection types). This seems to work fine if the master is working, but it fails if the master instance is down, even with the replica being available for the read operation.
I've tested a couple of scenerios whose outputs I've listed below, hopefully they are of some help.
Replication group (1 Master, 2 Replica) -- Master is down. Replica is up.
Command issued -- GEORADIUS_RO
Exception raised by lettuce -- io.lettuce.core.RedisException: Currently not connected. Commands are rejected.
This seems to happen due to the fact that lettuce doesn't have the command GEORADIUS_RO as readonly command in the file ReadOnlyCommands.java and thus it thinks it's a WRITE command and tries to execute it on a MASTER instance (which is not available).
Replication group (1 Master, 2 Replica) -- Master is down. Replica is up.
Command issued -- GEORADIUS
Exception raised by lettuce -- io.lettuce.core.RedisCommandExecutionException: READONLY You can't write against a read only replica.
This seems to fail likely due to the fact the command is sent to the REPLICA instance, but it errors out due to the fact that GEORADIUS is considered a WRITE command as per Redis docs.
I did find a commit which makes GEORADIUS use GEORADIUS_RO internally if available on a cluster, but it's only implemented for the cluster-enabled setups.
For now I've worked around the issue by compiling a local version of lettuce with adding GEORADIUS_RO as a read-only command in the ReadOnlyCommands.java.
Here's a small snippet that can be used to replicate the issue.
We added GEORADIUS_RO/GEORADIUSBYMEMBER_RO support to Redis Cluster initially as cluster connection initialization on Redis cluster is somewhat expensive and querying the Redis command set does not impact so much the connection creation, compared to standalone Redis. We should add both commands to the Master/Replica API ReadOnly command definition.
The ReadOnly variant is only required for Read-only nodes so I'm not sure whether it makes sense to add that kind of overhead to standalone Redis operations. Master/Replica connections use the same type of connections as standalone Redis as Master/Replica affects only the routing without further cluster-awareness.
GEORADIUS_RO and GEORADIUSBYMEMBER_RO are now enabled for replica routing. Likely, we will introduce in a future revision the support of CommandSet to determine command properties from Redis' COMMAND metadata.
Not sure if this is an actual issue or just me being dumb.
I have simple replication group setup with 1 master and 2 replicas (This is with the cluster-enabled config value set to
false
in the redis instance config). My goal is a have a setup where by default I am able to make READ command to the MASTER, but if it's down, the commands should be sent to the replicas. This becomes a bit tricky for the GEORADIUS command as it's considered a WRITE command by Redis.Using the
StatefulRedisMasterReplicationConnection
I am issuing a customGEORADIUS_RO
command with ReadFrom set toMASTER_PREFERRED
(there doesn't seem to be any in-built support forGEORADIUS_RO
for non-cluster-enabled connection types). This seems to work fine if the master is working, but it fails if the master instance is down, even with the replica being available for the read operation.I've tested a couple of scenerios whose outputs I've listed below, hopefully they are of some help.
Replication group (1 Master, 2 Replica) -- Master is down. Replica is up.
Command issued -- GEORADIUS_RO
Exception raised by lettuce --
io.lettuce.core.RedisException: Currently not connected. Commands are rejected.
This seems to happen due to the fact that lettuce doesn't have the command
GEORADIUS_RO
as readonly command in the fileReadOnlyCommands.java
and thus it thinks it's a WRITE command and tries to execute it on a MASTER instance (which is not available).Replication group (1 Master, 2 Replica) -- Master is down. Replica is up.
Command issued -- GEORADIUS
Exception raised by lettuce --
io.lettuce.core.RedisCommandExecutionException: READONLY You can't write against a read only replica.
This seems to fail likely due to the fact the command is sent to the REPLICA instance, but it errors out due to the fact that GEORADIUS is considered a WRITE command as per Redis docs.
I did find a commit which makes GEORADIUS use GEORADIUS_RO internally if available on a cluster, but it's only implemented for the cluster-enabled setups.
For now I've worked around the issue by compiling a local version of lettuce with adding
GEORADIUS_RO
as a read-only command in the ReadOnlyCommands.java.Here's a small snippet that can be used to replicate the issue.
Regards,
Leif
The text was updated successfully, but these errors were encountered: