From a6953e9e6e97fb67c280b588a0268c1285eefcfe Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Wed, 29 Sep 2021 11:28:53 +0300 Subject: [PATCH] Fixed - don't retry non-idempotent operations which were successfully sent. #3850 --- .../java/org/redisson/client/protocol/RedisCommands.java | 7 +++++++ .../src/main/java/org/redisson/command/RedisExecutor.java | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java index 717a41210..e93e50329 100644 --- a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java +++ b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java @@ -502,4 +502,11 @@ public interface RedisCommands { RedisStrictCommand> INFO_COMMANDSTATS = new RedisStrictCommand>("INFO", "COMMANDSTATS", new StringMapDataDecoder()); RedisStrictCommand> INFO_CLUSTER = new RedisStrictCommand>("INFO", "CLUSTER", new StringMapDataDecoder()); RedisStrictCommand> INFO_KEYSPACE = new RedisStrictCommand>("INFO", "KEYSPACE", new StringMapDataDecoder()); + + Set NO_RETRY = new HashSet<>( + Arrays.asList(LPOP.getName(), RPOP.getName(), LPUSH.getName(), RPUSH.getName(), + LPUSHX.getName(), RPUSHX.getName(), GEOADD.getName(), XADD.getName(), APPEND.getName(), + DECR.getName(), "DECRBY", INCR.getName(), INCRBY.getName(), ZINCRBY.getName(), + "HINCRBYFLOAT", "HINCRBY", "INCRBYFLOAT")); + } diff --git a/redisson/src/main/java/org/redisson/command/RedisExecutor.java b/redisson/src/main/java/org/redisson/command/RedisExecutor.java index 7a8a4c928..1c6587ec4 100644 --- a/redisson/src/main/java/org/redisson/command/RedisExecutor.java +++ b/redisson/src/main/java/org/redisson/command/RedisExecutor.java @@ -289,9 +289,7 @@ public class RedisExecutor { private void scheduleResponseTimeout(RPromise attemptPromise, RedisConnection connection) { long timeoutTime = responseTimeout; - if (command != null - && (RedisCommands.BLOCKING_COMMAND_NAMES.contains(command.getName()) - || RedisCommands.BLOCKING_COMMANDS.contains(command))) { + if (command != null && command.isBlockingCommand()) { Long popTimeout = null; if (RedisCommands.BLOCKING_COMMANDS.contains(command)) { for (int i = 0; i < params.length-1; i++) { @@ -343,7 +341,8 @@ public class RedisExecutor { } protected boolean isResendAllowed(int attempt, int attempts) { - return attempt < attempts; + return attempt < attempts + && (command == null || (!command.isBlockingCommand() && !RedisCommands.NO_RETRY.contains(command.getName()))); } private void handleBlockingOperations(RPromise attemptPromise, RedisConnection connection, Long popTimeout) {