Skip to content

Geosearch and FCALL_RO commands go to the master node #2568

Closed
@kajte

Description

@kajte

Bug Report

Current Behavior

geosearch commands go to master node even if read intention ReadFrom.REPLICA is specified.

Input Code

  1. Start simple master/replica redis setup with docker-compose
  2. Connect to both redis nodes and run MONITOR command to see commands coming to nodes
  3. Run java code
  4. Observe that geosearch command goes to primary node and get 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: good-first-issueAn issue that can only be worked on by brand new contributorstype: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions