diff --git a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java index 385d5ae7b..b3c150f89 100644 --- a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java +++ b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java @@ -747,14 +747,6 @@ public class CommandAsyncService implements CommandAsyncExecutor { TimerTask timeoutTask = new TimerTask() { @Override public void run(Timeout timeout) throws Exception { - MasterSlaveEntry entry = connectionManager.getEntry(connection.getRedisClient()); - if (entry != null) { - ClientConnectionsEntry ee = entry.getEntry(connection.getRedisClient()); - if (ee != null && ee.getNodeType() == NodeType.SLAVE) { - ee.trySetupFistFail(); - } - } - details.getAttemptPromise().tryFailure( new RedisResponseTimeoutException("Redis server response timeout (" + timeoutAmount + " ms) occured for command: " + details.getCommand() + " with params: " + LogHelper.toString(details.getParams()) + " channel: " + connection.getChannel())); @@ -910,16 +902,6 @@ public class CommandAsyncService implements CommandAsyncExecutor { free(details.getParams()); - if (!(future.cause() instanceof RedisTimeoutException) && details.getConnectionFuture().getNow() != null) { - MasterSlaveEntry entry = connectionManager.getEntry(details.getConnectionFuture().getNow().getRedisClient()); - if (entry != null) { - ClientConnectionsEntry ee = entry.getEntry(details.getConnectionFuture().getNow().getRedisClient()); - if (ee != null && ee.getNodeType() == NodeType.SLAVE) { - ee.resetFirstFail(); - } - } - } - if (future.isSuccess()) { R res = future.getNow(); if (res instanceof ScanResult) { diff --git a/redisson/src/main/java/org/redisson/connection/pool/ConnectionPool.java b/redisson/src/main/java/org/redisson/connection/pool/ConnectionPool.java index 6dbe5890b..0ba1552b8 100644 --- a/redisson/src/main/java/org/redisson/connection/pool/ConnectionPool.java +++ b/redisson/src/main/java/org/redisson/connection/pool/ConnectionPool.java @@ -271,11 +271,10 @@ abstract class ConnectionPool { } T conn = poll(entry); if (conn != null) { - if (!conn.isActive()) { - promiseFailure(entry, promise, conn); - return; - } - + if (!conn.isActive() && entry.getNodeType() == NodeType.SLAVE) { + entry.trySetupFistFail(); + } + connectedSuccessful(entry, promise, conn); return; } @@ -305,6 +304,10 @@ abstract class ConnectionPool { } private void connectedSuccessful(ClientConnectionsEntry entry, RPromise promise, T conn) { + if (conn.isActive() && entry.getNodeType() == NodeType.SLAVE) { + entry.resetFirstFail(); + } + if (!promise.trySuccess(conn)) { releaseConnection(entry, conn); releaseConnection(entry);