redis / jedis

Redis Java client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unable to connect to Google Memorystore

jasonschroeder-sfdc opened this issue · comments

Expected behavior

I'd like to use Jedis Cluster mode to connect to a MemoryStore Redis Cluster

Actual behavior

ClassCastException when parsing the reply from CLUSTER SHARDS command.

java.lang.ClassCastException: class [B cannot be cast to class java.lang.Long ([B and java.lang.Long are in module java.base of loader 'bootstrap')                                                                                 
    at redis.clients.jedis.BuilderFactory$57.build(BuilderFactory.java:1011)                                                                                                                                                        
    at redis.clients.jedis.BuilderFactory$57.build(BuilderFactory.java:1000)                                                                                                                                                        
    at redis.clients.jedis.BuilderFactory.createMapFromDecodingFunctions(BuilderFactory.java:1787)                                                                                                                                  
    at redis.clients.jedis.BuilderFactory.createMapFromDecodingFunctions(BuilderFactory.java:1761)                                                                                                                                  
    at redis.clients.jedis.BuilderFactory.access$100(BuilderFactory.java:16)                                                                                                                                                        
    at redis.clients.jedis.BuilderFactory$59.build(BuilderFactory.java:1090)                                                                                                                                                        
    at redis.clients.jedis.BuilderFactory$59.build(BuilderFactory.java:1064)                                                                                                                                                        
    at redis.clients.jedis.Jedis.clusterShards(Jedis.java:8840)                                                                        

It seems that the response from Google Memorystore cannot be deserialized here

The reply from redis-cli indicates these are not what's documented?

localhost:6379> CLUSTER SHARDS
1) 1) "slots"
   2) 1) "10923"   <-- Redis doc says they should be (integer)?
      2) "16383"   <-- Redis doc says they should be (integer)?
   3) "nodes"
   4) 1)  1) "id"
          2) "6d173e8ca045e8c531b61d0e9980acb63c8b8485"
          3) "port"
          4) (integer) 11004
          5) "tls-port"
          6) (integer) 11004
          7) "ip"
          8) "10.x.x.x" ----REDACTED----
          9) "endpoint"
         10) "10.x.x.x" ----REDACTED----
         11) "role"
         12) "master"
         13) "replication-offset"
         14) (integer) 2366
         15) "health"
         16) "online"

The documentation seems to indicate that the slots should be (integer)?

Steps to reproduce:

Please create a reproducible case of your problem. Make sure
that case repeats consistently and it's not random

  1. Provision Google Memorystore Redis Cluster without Replication and TLS enabled (In-transit encryption) - https://cloud.google.com/memorystore/docs/cluster
  2. Point Jedis at the Discovery Endpoint. https://cloud.google.com/memorystore/docs/cluster/connect-cluster-instance
  3. Convince JVM to not check Memorystore self-signed certificate

Redis / Jedis Configuration

GCP Memorystore Redis Cluster

Jedis version:

Jedis 5.1.2

Redis version:

Memorystore Redis Cluster

Java version:

Azul Openjdk 17

JedisCluster is not dependent on CLUSTER SHARDS command (yet). Ref: #2985

@sazzad16 - Thank you for triaging so quickly!

Are you saying that the Jedis.clusterShards() method is known to be broken? I am calling that in my code and getting the ClassCastException.

Are you saying that the Jedis.clusterShards() method is known to be broken?

Nothing that I am aware of.
Moreover, we have never received such bug report.

I am calling that in my code and getting the ClassCastException.

As you've already mentioned, the reply is not according to redis documentation which is the base for Jedis implementation. We cannot help in such cases.

For posterity, I want to confirm that we, Google Memorystore, will be fixing this incompatibility issue on our end soon.