scala-redis icon indicating copy to clipboard operation
scala-redis copied to clipboard

getting error java.lang.Exception: MOVED 2340 127.0.0.1:6301

Open kemul opened this issue 7 years ago • 13 comments

Dear All,

i already used redis-cluster, but always get exception every put to redis-cluster

java.lang.Exception: MOVED 2340 10.2.15.40:6301

val nodes = Array( ClusterNode("node1", "127.0.0.1, 6301), ClusterNode("node2", "127.0.0.1", 6302) ) val r = new RedisCluster(new mutable.WrappedArray.ofRef(nodes): _*) { val keyTag = Some(RegexKeyTag) }

on other side, when use that cluster client

redis.processForKey (keyVal)(_.setex (keyVal, ttl, value))

redis-key is like

{key-1:123} {key-2:123}

can some help my issue ?

kemul avatar Oct 25 '16 11:10 kemul

I tried this last week but I learned that RedisClient does support Redis Cluster yet.

Seyun avatar Nov 14 '16 02:11 Seyun

Set up Redis cluster with master (30001, 30002, 30003) and slaves (30004, 30005, 30006) Connection test with native Redis-client succeed

import com.redis._
import java.net.{ServerSocket, Socket}
import java.io._
import collection.mutable.WrappedArray

val redislist = Array(("localhost", 30001), ("localhost", 30002), ("localhost", 30003))

val nodes = redislist.map { case (host, port) =>
    cluster.ClusterNode(host+":"+port, host, port)
}
val r = new cluster.RedisCluster(new WrappedArray.ofRef(nodes): _*) {
    val keyTag = Some(cluster.RegexKeyTag)
}
r.set("0", 0)

Will cause error

java.lang.Exception: MOVED 13907 127.0.0.1:30003
  at com.redis.Reply$$anonfun$8.applyOrElse(RedisProtocol.scala:120)
  at com.redis.Reply$$anonfun$8.applyOrElse(RedisProtocol.scala:119)
  at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36)
  at com.redis.Reply$$anonfun$3.applyOrElse(RedisProtocol.scala:64)
  at com.redis.Reply$$anonfun$3.applyOrElse(RedisProtocol.scala:64)
  at scala.PartialFunction$OrElse.apply(PartialFunction.scala:167)
  at com.redis.Reply$$anonfun$1.applyOrElse(RedisProtocol.scala:54)
  at com.redis.Reply$$anonfun$1.applyOrElse(RedisProtocol.scala:54)
  at scala.PartialFunction$OrElse.apply(PartialFunction.scala:167)
  at com.redis.Reply$class.receive(RedisProtocol.scala:140)
  at com.redis.RedisClient.receive(RedisClient.scala:95)
  at com.redis.R$class.asBoolean(RedisProtocol.scala:253)
  at com.redis.RedisClient.asBoolean(RedisClient.scala:95)
  at com.redis.StringOperations$$anonfun$set$1.apply$mcZ$sp(StringOperations.scala:10)
  at com.redis.StringOperations$$anonfun$set$1.apply(StringOperations.scala:10)
  at com.redis.StringOperations$$anonfun$set$1.apply(StringOperations.scala:10)
  at com.redis.Redis$class.send(RedisClient.scala:22)
  at com.redis.RedisClient.send(RedisClient.scala:95)
  at com.redis.StringOperations$class.set(StringOperations.scala:10)
  at com.redis.RedisClient.set(RedisClient.scala:95)
  at com.redis.cluster.RedisCluster$$anonfun$set$1.apply(RedisCluster.scala:181)
  at com.redis.cluster.RedisCluster$$anonfun$set$1.apply(RedisCluster.scala:181)
  at com.redis.cluster.RedisCluster$$anonfun$processForKey$1.apply(RedisCluster.scala:88)
  at com.redis.cluster.RedisCluster$$anonfun$processForKey$1.apply(RedisCluster.scala:88)
  at com.redis.RedisClientPool.withClient(Pool.scala:45)
  at com.redis.cluster.RedisCluster.processForKey(RedisCluster.scala:88)
  at com.redis.cluster.RedisCluster.set(RedisCluster.scala:181)
  ... 42 elided

Further investigation:

r.set("0", 0) => java.lang.Exception: MOVED 14039 127.0.0.1:30003
r.set("1", 1) => OK
r.set("2", 2) => OK
r.set("3", 3) => java.lang.Exception: MOVED 14039 127.0.0.1:30001
r.set("4", 4) => java.lang.Exception: MOVED 14039 127.0.0.1:30003
r.set("5", 5) => OK
r.set("6", 6) => OK
r.set("7", 7) => java.lang.Exception: MOVED 14039 127.0.0.1:30001
r.set("8", 8) => java.lang.Exception: MOVED 14039 127.0.0.1:30003
r.set("9", 9) => OK

Apparently there is a pattern in it. Not sure what's the problem yet.


Update: Issue probably caused by Redis configuration: #https://github.com/StackExchange/StackExchange.Redis/issues/179

Wei-1 avatar Feb 16 '17 03:02 Wei-1

Thanks for reporting .. will look into it over the weekend.

debasishg avatar Feb 16 '17 05:02 debasishg

Any update here? I see this as well.

mnarrell avatar May 19 '17 14:05 mnarrell

I did take a look but got swamped into other stuff. I will take a detailed look over the weekend. Sorry for not fixing it earlier ..

debasishg avatar May 19 '17 14:05 debasishg

@Seyun is correct .. redisclient doesn't support Redis Cluster as in https://redis.io/topics/cluster-spec .. The cluster that's implemented is something homegrown. I need to work on support for the native cluster. But currently I have no time and hence no promise on the timeline :-( .. However if anyone has a PR will gratefully accept it :-)

debasishg avatar May 20 '17 15:05 debasishg

@debasishg Is there any update on this?

danielyli avatar Dec 02 '17 05:12 danielyli

Unfortunately no :-( .. Too swamped into other stuff, lots of traveling as well. Let me try and spend some time during the Christmas holidays ..

debasishg avatar Dec 04 '17 06:12 debasishg

Evaluating scala drivers for redis and get same error. Any plans to work on it?

aksharp avatar Sep 02 '18 13:09 aksharp

i hava the same trobule , how can i solve it

Just2017 avatar Nov 12 '18 15:11 Just2017

Unfortunately I still have no bandwidth to work on this. Just curious has anyone been working on integrating redis cluster with redisclient ?

debasishg avatar Nov 12 '18 16:11 debasishg

IMHO, just using redisclient will be hard to integrate with Redis cluster. A cluster connector is pretty much needed, like what Jedis had done here My company ended up wrote a Scala port based on Jedis Cluster.

Wei-1 avatar Nov 12 '18 17:11 Wei-1

Unfortunately I still have no bandwidth to work on this. Just curious has anyone been working on integrating redis cluster with redisclient ?

Will you add support in any time soon?

sourabhlk avatar Nov 21 '18 08:11 sourabhlk