Closed
Description
Bug Report
Current Behavior
geosearch
commands go to master node even if read intention ReadFrom.REPLICA
is specified.
Input Code
- Start simple master/replica redis setup with docker-compose
- Connect to both redis nodes and run
MONITOR
command to see commands coming to nodes - Run java code
- Observe that
geosearch
command goes to primary node andget
replica node
# docker-compose.yaml
version: "3.9"
services:
redis-master:
image: "redis"
ports:
- "6379:6379"
expose:
- "6379"
redis-replica:
image: "redis"
ports:
- '6380:6379'
command: redis-server --slaveof redis-master 6379
// Main.java
package org.example;
import io.lettuce.core.*;
import io.lettuce.core.codec.StringCodec;
import io.lettuce.core.masterreplica.MasterReplica;
import io.lettuce.core.masterreplica.StatefulRedisMasterReplicaConnection;
import java.util.List;
public class Main {
public static void main(String[] args) {
RedisURI masterUri = RedisURI.create("redis://localhost:6379");
RedisURI replicaUri = RedisURI.create("redis://localhost:6380");
RedisClient client = RedisClient.create();
List<RedisURI> nodes = List.of(masterUri, replicaUri);
StatefulRedisMasterReplicaConnection<String, String> connection = MasterReplica.connect(client, StringCodec.UTF8, nodes);
connection.setReadFrom(ReadFrom.REPLICA);
connection.sync().get("key");
connection.sync().geosearch("another-key", GeoSearch.fromCoordinates(0.0, 0.0), GeoSearch.byRadius(1.0, GeoArgs.Unit.km));
}
}
Expected behavior/code
geosearch
commands should go to replica node when read intention ReadFrom.REPLICA
is specified as the command (https://redis.io/commands/geosearch/) is only reading.
Environment
- Lettuce version: Tested with
6.3.0.RELEASE
but I believe other versions are affected too - Redis version: 7.2.3
Possible Solution
Add geosearch
to the list of read_only commands similar to #2198 did for smismember
. I can open a PR to do that.