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

Alexander Lapin edited comment on IGNITE-21644 at 3/8/24 3:05 PM:
------------------------------------------------------------------

@Aleksandr Belyak Test code is incorrect. putAllAsync calls aren’t linearized 
because second putAllAsync as method param is evaluated on method call and not 
within inner fut.thenCompose. It’s possible to either rewrite thenCompose 
method or e.g. use Supplier in order to evaluate second putAllAsync in a lazy 
manner. First option is better, having such method is error prone.

Besides lack of linearization thenCompose method doesn’t return result of 
fut.thenCompose(r -> fn); thus you actually await only first operation result. 
Please use 
{code:java}
return fut.thenCompose() {code}
 instead.


was (Author: alapin):
@Aleksandr Belyak Test code is incorrect. putAllAsync calls aren’t linearized 
because second putAllAsync as method param is evaluated on method call and not 
within inner fut.thenCompose. It’s possible to either rewrite thenCompose 
method or e.g. use Supplier in order to evaluate second putAllAsync in a lazy 
manner. First option is better, having such method is error prone.

Besides lack of linearization thenCompose method doesn’t return result of 
fut.thenCompose(r -> fn); thus you actually await only first operation result. 
Please use return `fut.thenCompose() instead.`

> Deadlock prevention makes Java Async APIs (KV/RV) hard to use
> -------------------------------------------------------------
>
>                 Key: IGNITE-21644
>                 URL: https://issues.apache.org/jira/browse/IGNITE-21644
>             Project: Ignite
>          Issue Type: Bug
>          Components: persistence
>    Affects Versions: 3.0
>            Reporter: Alexander Belyak
>            Priority: Major
>
> # Create table T1
>  # Get KeyValue view or Record View
>  # Make a batch of 100 rows and call CompletableFuture f = 
> view.putAllAsync(null , batch) or view.
> upsertAllAsync(null, batch)
>  # Make another batch and compose it with the first CompletableFuture with: 
> f.thenCompose(r -> view.putAllAsync(null, newBatch));
> Expected behavior: batch completed sucessfully.
> Actual behavior: Failed to acquire a lock due to a possible deadlock



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

Reply via email to