Konstantin Orlov created IGNITE-18868:
-----------------------------------------

             Summary: Recursive update of pendingInvokes in ReplicaService
                 Key: IGNITE-18868
                 URL: https://issues.apache.org/jira/browse/IGNITE-18868
             Project: Ignite
          Issue Type: Bug
            Reporter: Konstantin Orlov


Take a look at the code below:
{code:java}
// ReplicaService#sendToReplica
           if (errResp.throwable() instanceof ReplicaUnavailableException) {
                        pendingInvokes.compute(targetNodeConsistentId, 
(clusterNode, fut) -> {
                            if (fut == null) {
                                AwaitReplicaRequest awaitReplicaReq = ...

                                fut = messagingService.invoke(...)
                                        .whenComplete((response0, throwable0) 
-> {
                                            
pendingInvokes.remove(targetNodeConsistentId);
                                        });
                            }
{code}
In case {{messagingService}} respond immediately, {{whenComplete}} callback 
will be executed in the same thread causing recursive update ({{remove}} inside 
of {{compute}}) which is not allowed.


{code:java}
Caused by: java.lang.IllegalStateException: Recursive update
        at 
java.base/java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1167)
        at 
java.base/java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1102)
        at 
org.apache.ignite.internal.replicator.ReplicaService.lambda$sendToReplica$0(ReplicaService.java:125)
        at 
java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859)
        at 
java.base/java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:883)
        at 
java.base/java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2251)
        at 
org.apache.ignite.internal.replicator.ReplicaService.lambda$sendToReplica$3(ReplicaService.java:124)

{code}




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to