-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jedis-3.2.0 JedisClusterMaxAttemptsException connect to redis-5.0.7 cluster #2130
Comments
When the Cluster is abnormal, Jedis will provide retries. The default number of retries is 5, see redis.clients.jedis.BinaryJedisCluster#DEFAULT_MAX_ATTEMPTS. You can specify more retries through the following construction method.
But I don't recommend that you set maxAttempts too large, otherwise it may cause |
@DoverDee What is the output of |
Closed due to inactivity. |
This PR would provide retries with backoff, giving the cluster a chance to come back: #2358 |
May I ask how this problem was finally dealt with. |
Running into the same issue in our production env right now and cannot replicate locally. Any guidance would be appreciated. |
Expected behavior
when kill 7000 master node , the code will appear exception,
wait a moment, the slave instead of 7000 master node, the exception should be disappear.
but still pose exception .
Java code
public static void clusterConnJedis() {
Set clusterNodes = new HashSet();
HostAndPort hp7000 = new HostAndPort("172.16.1.41", 7000);
HostAndPort hp7001 = new HostAndPort("172.16.1.41", 7001);
HostAndPort hp7002 = new HostAndPort("172.16.1.41", 7002);
HostAndPort hp7003 = new HostAndPort("172.16.1.41", 7003);
HostAndPort hp7004 = new HostAndPort("172.16.1.41", 7004);
HostAndPort hp7005 = new HostAndPort("172.16.1.41", 7005);
clusterNodes.add(hp7000);
clusterNodes.add(hp7001);
clusterNodes.add(hp7002);
clusterNodes.add(hp7003);
clusterNodes.add(hp7004);
clusterNodes.add(hp7005);
JedisCluster clusterPool = null;
while (true) {
try {
clusterPool = new JedisCluster(clusterNodes, 5000, new JedisPoolConfig());
int index = new Random().nextInt(100000);
String key = "k-" + index;
String value = "v-" + index;
clusterPool.set(key, value);
System.out.println("key:value=" + key + ":" + clusterPool.get(key));
TimeUnit.MILLISECONDS.sleep(500);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != clusterPool) {
clusterPool.close();
}
}
}
}
Actual behavior and Steps to reproduce:
Redis cluster just installed and runing, run TestClass.clusterConnJedis(); in main method. everything is ok , I find the right pint key:value=k-RandomNum:v-RandomNum per 500 MILLISECONDS in conole.
But when I command ' kill -p ${hp7000_ pid}' , 7000 master node be killed. I find the console print
JedisClusterMaxAttemptsException several normal print intervals.
exception details:
redis.clients.jedis.exceptions.JedisClusterMaxAttemptsException: No more cluster attempts left.
at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:86)
at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:124)
at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:124)
at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:124)
at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:124)
at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:124)
at redis.clients.jedis.JedisClusterCommand.run(JedisClusterCommand.java:25)
at redis.clients.jedis.JedisCluster.set(JedisCluster.java:143)
at Test.clusterConnJedis(Test.java:69)
at Test.main(Test.java:11)
exception picture:
Redis / Jedis Configuration
see code clusterConnJedis()
Jedis version:
jedis-3.2.0
Redis version:
redis-5.0.7 cluster
Java version:
jdk1.8.0.211
The text was updated successfully, but these errors were encountered: