sanpwc commented on code in PR #1168:
URL: https://github.com/apache/ignite-3/pull/1168#discussion_r989354245


##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/TransactionImpl.java:
##########
@@ -54,10 +56,13 @@ public class TransactionImpl implements InternalTransaction 
{
     private final TxManager txManager;
 
     /** Enlisted replication groups: replication group id -> (primary replica 
node, raft term). */
-    private Map<String, IgniteBiTuple<ClusterNode, Long>> enlisted = new 
ConcurrentSkipListMap<>();
+    private final Map<String, IgniteBiTuple<ClusterNode, Long>> enlisted = new 
ConcurrentSkipListMap<>();
 
     /** Enlisted operation futures in this transaction. */
-    private volatile List<CompletableFuture<?>>  enlistedResults = new 
ArrayList<>();
+    private final List<CompletableFuture<?>> enlistedResults = new 
ArrayList<>();
+
+    /** Guard that prevents finishing or enlisting new operations into already 
finished or finishing transaction. */
+    private boolean txInFinishState = false;

Review Comment:
   Because it's required not only to change txInFinishState atomically but also 
to populate enlistedResults with new value
   ```
       public synchronized void enlistResultFuture(CompletableFuture<?> 
resultFuture) {
           if (txInFinishState) {
               throw new TransactionException(TX_ALREADY_FINISHED_ERR,
                       "Failed to enlist operation into already finished 
transaction txId={" + id + '}');
           }
   
           enlistedResults.add(resultFuture);
       }
   ```



-- 
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