This is an automated email from the ASF dual-hosted git repository.

rpuch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new fa0b264448 IGNITE-24112 Retry in RaftGroupServiceImpl on a 
RecipientLeftException (#4967)
fa0b264448 is described below

commit fa0b264448b5e6ceb83b38f07d6467c52f726ba7
Author: Roman Puchkovskiy <[email protected]>
AuthorDate: Wed Dec 25 14:05:17 2024 +0400

    IGNITE-24112 Retry in RaftGroupServiceImpl on a RecipientLeftException 
(#4967)
---
 .../apache/ignite/internal/raft/RaftGroupServiceImpl.java   |  6 +++++-
 .../apache/ignite/internal/raft/RaftGroupServiceTest.java   | 13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/RaftGroupServiceImpl.java
 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/RaftGroupServiceImpl.java
index 901f03baf7..4dce2bd43c 100644
--- 
a/modules/raft/src/main/java/org/apache/ignite/internal/raft/RaftGroupServiceImpl.java
+++ 
b/modules/raft/src/main/java/org/apache/ignite/internal/raft/RaftGroupServiceImpl.java
@@ -63,6 +63,7 @@ import org.apache.ignite.internal.logger.IgniteLogger;
 import org.apache.ignite.internal.logger.Loggers;
 import org.apache.ignite.internal.network.ClusterService;
 import org.apache.ignite.internal.network.NetworkMessage;
+import org.apache.ignite.internal.network.RecipientLeftException;
 import org.apache.ignite.internal.raft.configuration.RaftConfiguration;
 import org.apache.ignite.internal.raft.service.LeaderWithTerm;
 import org.apache.ignite.internal.raft.service.RaftGroupService;
@@ -799,7 +800,10 @@ public class RaftGroupServiceImpl implements 
RaftGroupService {
     private static boolean recoverable(Throwable t) {
         t = unwrapCause(t);
 
-        return t instanceof TimeoutException || t instanceof IOException || t 
instanceof PeerUnavailableException;
+        return t instanceof TimeoutException
+                || t instanceof IOException
+                || t instanceof PeerUnavailableException
+                || t instanceof RecipientLeftException;
     }
 
     private Peer randomNode() {
diff --git 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/RaftGroupServiceTest.java
 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/RaftGroupServiceTest.java
index 96ff82c7d2..9da3d3e903 100644
--- 
a/modules/raft/src/test/java/org/apache/ignite/internal/raft/RaftGroupServiceTest.java
+++ 
b/modules/raft/src/test/java/org/apache/ignite/internal/raft/RaftGroupServiceTest.java
@@ -64,6 +64,7 @@ import 
org.apache.ignite.internal.lang.IgniteInternalException;
 import org.apache.ignite.internal.network.ClusterNodeImpl;
 import org.apache.ignite.internal.network.ClusterService;
 import org.apache.ignite.internal.network.MessagingService;
+import org.apache.ignite.internal.network.RecipientLeftException;
 import org.apache.ignite.internal.network.TopologyService;
 import 
org.apache.ignite.internal.network.serialization.MessageSerializationRegistry;
 import org.apache.ignite.internal.network.utils.ClusterServiceTestUtils;
@@ -699,6 +700,18 @@ public class RaftGroupServiceTest extends 
BaseIgniteAbstractTest {
         assertThat(service.leader(), is(NODES.get(NODES.size() - 1)));
     }
 
+    @Test
+    public void testRetryOnRecipientLeftException() {
+        when(messagingService.invoke(any(ClusterNode.class), 
any(ReadActionRequest.class), anyLong()))
+                .thenReturn(failedFuture(new RecipientLeftException()));
+
+        RaftGroupService service = 
startRaftGroupServiceWithRefreshLeader(NODES);
+
+        CompletableFuture<Object> response = 
service.run(mock(ReadCommand.class));
+
+        assertThat(response, willThrow(TimeoutException.class, "Send with 
retry timed out"));
+    }
+
     private RaftGroupService startRaftGroupService(List<Peer> peers) {
         PeersAndLearners memberConfiguration = 
PeersAndLearners.fromPeers(peers, Set.of());
 

Reply via email to