From 38c74cd8e7097704eb84e665888ee87e3c0ba101 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 6 Feb 2023 12:28:54 +0300 Subject: [PATCH] Fixed - a new attempt should be made on WAIT error during failover. #4822 --- .../redisson/client/RedisWaitException.java | 31 +++++++++++++++++++ .../client/handler/CommandDecoder.java | 5 ++- .../org/redisson/command/RedisExecutor.java | 3 +- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 redisson/src/main/java/org/redisson/client/RedisWaitException.java diff --git a/redisson/src/main/java/org/redisson/client/RedisWaitException.java b/redisson/src/main/java/org/redisson/client/RedisWaitException.java new file mode 100644 index 000000000..202251a72 --- /dev/null +++ b/redisson/src/main/java/org/redisson/client/RedisWaitException.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2013-2022 Nikita Koksharov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.redisson.client; + +/** + * This error occurs when Redis server is busy. + * + * @author Nikita Koksharov + * + */ +public class RedisWaitException extends RedisException{ + + private static final long serialVersionUID = -5658453331593019251L; + + public RedisWaitException(String message) { + super(message); + } +} diff --git a/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java b/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java index 798ee6d1b..4e1cd6220 100644 --- a/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java +++ b/redisson/src/main/java/org/redisson/client/handler/CommandDecoder.java @@ -372,7 +372,10 @@ public class CommandDecoder extends ReplayingDecoder { } else if (error.startsWith("BUSY")) { data.tryFailure(new RedisBusyException(error + ". channel: " + channel + " data: " + data)); - } else { + } else if (error.startsWith("WAIT")) { + data.tryFailure(new RedisWaitException(error + + ". channel: " + channel + " data: " + data)); + }else { if (data != null) { data.tryFailure(new RedisException(error + ". channel: " + channel + " command: " + LogHelper.toString(data))); } else { diff --git a/redisson/src/main/java/org/redisson/command/RedisExecutor.java b/redisson/src/main/java/org/redisson/command/RedisExecutor.java index 4d1a7e73e..6f5f98c5d 100644 --- a/redisson/src/main/java/org/redisson/command/RedisExecutor.java +++ b/redisson/src/main/java/org/redisson/command/RedisExecutor.java @@ -523,7 +523,8 @@ public class RedisExecutor { if (cause instanceof RedisLoadingException || cause instanceof RedisTryAgainException || cause instanceof RedisClusterDownException - || cause instanceof RedisBusyException) { + || cause instanceof RedisBusyException + || cause instanceof RedisWaitException) { if (attempt < attempts) { onException(); connectionManager.newTimeout(timeout -> {