JedisCluster throws JedisClusterMaxRedirectionsException: Too many Cluster redirections?
See original GitHub issuehi, i tested JedisCluster, it’s very very slow and throws an exception,
here is the code:
Set<HostAndPort> nodes = new HashSet<HostAndPort>();
nodes.add(new HostAndPort("192.168.2.65", 6379));
nodes.add(new HostAndPort("192.168.2.65", 6380));
nodes.add(new HostAndPort("192.168.2.65", 6381));
nodes.add(new HostAndPort("192.168.2.65", 6382));
nodes.add(new HostAndPort("192.168.2.65", 6383));
nodes.add(new HostAndPort("192.168.2.65", 6384));
JedisCluster jedisCluster = new JedisCluster(nodes, 30 * 2000);
int k = 16384;
for (int i = 0; i < k; i++) {
long l = System.currentTimeMillis();
jedisCluster.set(i + "", i + "" + i);
System.out.println(i + " use " + (System.currentTimeMillis() - l));
}
jedisCluster.close();
and the exception:
Exception in thread “main” redis.clients.jedis.exceptions.JedisClusterMaxRedirectionsException:Too many Cluster redirections? at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:34) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:67) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:83) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:67) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:83) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:67) at redis.clients.jedis.JedisClusterCommand.run(JedisClusterCommand.java:29) at redis.clients.jedis.JedisCluster.set(JedisCluster.java:70) at me.binge.redis.test.RedisClusterExecutorTest.main(RedisClusterExecutorTest.java:26)
test env:
- Redis version: 3.0.0 stable
- Jedis version: 2.7.0
- It works fine when using Jedis.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10
sorry, my bad. i found the reason, when i create the cluster, use command like this:
./redis-trib.rb create --replicas 1 127.0.0.1:6379 127.0.0.1:6381 127.0.0.1:6383 127.0.0.1:6380 127.0.0.1:6382 127.0.0.1:6383
then jedis get the cluster info, the ip of the node is also 127.0.0.1, so can’t get connection and retry. so i recreate the cluster use:./redis-trib.rb create --replicas 1 192.168.2.65:6379 192.168.2.65:6381 192.168.2.65:6383 192.168.2.65:6380 192.168.2.65:6382 192.168.2.65:6384
it works.
There’s one thing I need to mention. Be sure to delete all aof, rdb, conf files before re-running redis-trib.rb