You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Vladislav Pyatkov (Jira)" <ji...@apache.org> on 2023/03/27 17:35:00 UTC

[jira] [Commented] (IGNITE-18868) Recursive update of pendingInvokes in ReplicaService

    [ https://issues.apache.org/jira/browse/IGNITE-18868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17705471#comment-17705471 ] 

Vladislav Pyatkov commented on IGNITE-18868:
--------------------------------------------

I had already fixed the issue in IGNITE-19022, here I unmuted test and sightly modify it.

> 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
>            Assignee: Vladislav Pyatkov
>            Priority: Major
>              Labels: ignite-3
>
> h3. Motivation
> 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}
> a
> h3. Definition of Done
> Need to move 
> {code:java}
> .whenComplete(
>     (response0, throwable0) -> { pendingInvokes.remove(targetNodeConsistentId); }
> );
> {code}
> from the _compute_ block and add it to the future which is returned from the {_}compute{_}.



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