From e70c91b7f93a8541508aca58e7903d7f41d8500e Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Wed, 27 Jan 2021 11:05:23 +0300 Subject: [PATCH] Fixed - MOVED or ASK response from Redis causes "Unable to acquire connection!" error. #3370 --- .../org/redisson/command/RedisExecutor.java | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/redisson/src/main/java/org/redisson/command/RedisExecutor.java b/redisson/src/main/java/org/redisson/command/RedisExecutor.java index 1351779e7..88a402269 100644 --- a/redisson/src/main/java/org/redisson/command/RedisExecutor.java +++ b/redisson/src/main/java/org/redisson/command/RedisExecutor.java @@ -156,11 +156,11 @@ public class RedisExecutor { checkWriteFuture(writeFuture, attemptPromise, connection); } }); - - releaseConnection(attemptPromise, connectionFuture); }); attemptPromise.onComplete((r, e) -> { + releaseConnection(attemptPromise, connectionFuture); + checkAttemptPromise(attemptPromise, connectionFuture); }); } @@ -624,24 +624,22 @@ public class RedisExecutor { } protected void releaseConnection(RPromise attemptPromise, RFuture connectionFuture) { - attemptPromise.onComplete((res, e) -> { - if (!connectionFuture.isSuccess()) { - return; - } + if (!connectionFuture.isSuccess()) { + return; + } - RedisConnection connection = connectionFuture.getNow(); - connectionManager.getShutdownLatch().release(); - if (readOnlyMode) { - connectionManager.releaseRead(source, connection); - } else { - connectionManager.releaseWrite(source, connection); - } + RedisConnection connection = connectionFuture.getNow(); + connectionManager.getShutdownLatch().release(); + if (readOnlyMode) { + connectionManager.releaseRead(source, connection); + } else { + connectionManager.releaseWrite(source, connection); + } - if (log.isDebugEnabled()) { - log.debug("connection released for command {} and params {} from slot {} using connection {}", - command, LogHelper.toString(params), source, connection); - } - }); + if (log.isDebugEnabled()) { + log.debug("connection released for command {} and params {} from slot {} using connection {}", + command, LogHelper.toString(params), source, connection); + } } public RedisClient getRedisClient() {