Cyrill commented on code in PR #3436:
URL: https://github.com/apache/ignite-3/pull/3436#discussion_r1534054293


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -1894,18 +1893,23 @@ private <T> CompletableFuture<T> appendTxCommand(UUID 
txId, RequestType cmdType,
         var cleanupReadyFut = new CompletableFuture<Void>();
 
         txCleanupReadyFutures.compute(txId, (id, txOps) -> {
-            if (txOps == null) {
-                txOps = new TxCleanupReadyFutureList();
-            }
-
+            // First check whether the transaction has already been finished.
+            // And complete cleanupReadyFut with exception if it is the case.
             TxStateMeta txStateMeta = txManager.stateMeta(txId);
 
             if (txStateMeta == null || isFinalState(txStateMeta.txState())) {
                 cleanupReadyFut.completeExceptionally(new Exception());
-            } else {
-                txOps.futures.computeIfAbsent(cmdType, type -> new 
ArrayList<>()).add(cleanupReadyFut);
+
+                return txOps;

Review Comment:
   Imagine we went into the `if`, block, in other words, the transaction has 
finished and the request is trying to execute on a finished transaction.
   There are two options - the cleanup has already finished or has not yet 
started, that means `txCleanupReadyFutures.compute...` from 
`awaitCleanupReadyFutures` either has already been called or is going to be 
called later.
   
   If `awaitCleanupReadyFutures` has already been called, then the value of 
txOps is null and we return null.
   If not - then txOps!=null and we will use it to wait on the corresponding 
futures later.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to