Hello,
I am getting the wrong response for jedis command. SlaveOf is just the example here but I am getting other calls in the code and I am getting the same behavior.
Current Jedis version: 3.4.1
I am creating jedisPool using this and there is just one single redis server I am trying to connect:
jedisPoolConfig.setJmxEnabled(false);
this.jedisPool = new AuthAwareJedisPool(jedisPoolConfig, hostText, port, timeout, password, ssl);
this.host = hostText;
this.port = port;
Here is the code snippet:
String status = jedis.slaveof(host, Integer.valueOf(port));
if (status == null || !"OK".equals(status)) {
logger.warn("Failed to make a slaveof {}:{}, status:{}", host, port, status);
}
error Msg:
Failed to make a slaveof <IP>:6379, status:# Keyspace
db0:keys=2,expires=0,avg_ttl=0
As you can see above, I am getting the response status for the keyspace command instead of slaveof command. I don't always get the wrong response. This code runs into an application container and over time(maybe in 1-2 days), it starts spitting the wrong response for the command expected here (it is really very random). I am getting a similar behavior for configSet as well.
String status = jedis.configSet(entry.getKey(), entry.getValue());
if (status == null || !"OK".equals(status)) {
logger.error("exception while writing config for key: {}, value: {}, status: {}", entry.getKey(),
entry.getValue(), status);
when It gets the msg for status, it is not OK but of a different redis command.
I referred to the older thread/issue on git
https://github.com/redis/jedis/issues/909 for the same. I can see some enhancements were made since then by deprecating some methods and I am using Jedis 3.4.1 here.
Should I just use JedisConnectionException as a strategy here to capture the wrong response and simply call Jedis.close() so the bad connection is closed and JedisPool takes care of adding a new connection to the pool and surround each call with that? Or something else I am missing here.
However, I am getting the response as status here hence I believe it was executed correctly without any exception so I am not even sure if it is a bad connection.
For example: there are internal checks for internal method of jedis for connection check:
public String configSet(String parameter, String value) {
this.checkIsInMultiOrPipeline();
this.client.configSet(parameter, value);
return this.client.getStatusCodeReply();
}
I am looking for any suggestions or help here.
Thanks.