From 153841e067f96091ecfdd6fa6f080163be3015c1 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Thu, 20 Apr 2023 21:20:03 +0600 Subject: [PATCH] Revert Sharded Jedis related changes from "Avoid using QUIT command (#3377)" This partially reverts commit 1787d311c1b9354ac3d6a9ed81cbd56c4e1b664d. --- .../java/redis/clients/jedis/BinaryShardedJedis.java | 11 ++++++++++- .../java/redis/clients/jedis/ShardedJedisPool.java | 10 +++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/redis/clients/jedis/BinaryShardedJedis.java b/src/main/java/redis/clients/jedis/BinaryShardedJedis.java index e3db4bfa8f..a65f230adb 100644 --- a/src/main/java/redis/clients/jedis/BinaryShardedJedis.java +++ b/src/main/java/redis/clients/jedis/BinaryShardedJedis.java @@ -58,11 +58,20 @@ public BinaryShardedJedis(List shards, Hashing algo, Pattern key public void disconnect() { for (Jedis jedis : getAllShards()) { if (jedis.isConnected()) { + try { + // need a proper test, probably with mock + if (!jedis.isBroken()) { + jedis.quit(); + } + } catch (JedisConnectionException e) { + // ignore the exception node, so that all other normal nodes can release all connections. + logger.warn("Error while QUIT", e); + } try { jedis.disconnect(); } catch (JedisConnectionException e) { // ignore the exception node, so that all other normal nodes can release all connections. - logger.debug("Error while disconnect", e); + logger.warn("Error while disconnect", e); } } } diff --git a/src/main/java/redis/clients/jedis/ShardedJedisPool.java b/src/main/java/redis/clients/jedis/ShardedJedisPool.java index 33ab91c218..2d8dbcdf86 100644 --- a/src/main/java/redis/clients/jedis/ShardedJedisPool.java +++ b/src/main/java/redis/clients/jedis/ShardedJedisPool.java @@ -87,10 +87,18 @@ public void destroyObject(PooledObject pooledShardedJedis) throws final ShardedJedis shardedJedis = pooledShardedJedis.getObject(); for (Jedis jedis : shardedJedis.getAllShards()) { if (jedis.isConnected()) { + try { + // need a proper test, probably with mock + if (!jedis.isBroken()) { + jedis.quit(); + } + } catch (RuntimeException e) { + logger.warn("Error while QUIT", e); + } try { jedis.disconnect(); } catch (RuntimeException e) { - logger.debug("Error while disconnect", e); + logger.warn("Error while disconnect", e); } } }