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


##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/ReadWriteTransactionImpl.java:
##########
@@ -88,8 +93,12 @@ public IgniteBiTuple<ClusterNode, Long> 
enlist(ReplicationGroupId replicationGro
     /** {@inheritDoc} */
     @Override
     protected CompletableFuture<Void> finish(boolean commit) {
+        if (!finishFut.compareAndSet(null, new CompletableFuture<>())) {
+            return finishFut.get();
+        }
+
         // TODO: https://issues.apache.org/jira/browse/IGNITE-17688 Add proper 
exception handling.
-        return CompletableFuture
+        CompletableFuture<Void> mainFinishFut = CompletableFuture

Review Comment:
   Naming is a little bit confusing. Do you have any other options? Up to you, 
though.



##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/ReadWriteTransactionImpl.java:
##########
@@ -88,8 +93,12 @@ public IgniteBiTuple<ClusterNode, Long> 
enlist(ReplicationGroupId replicationGro
     /** {@inheritDoc} */
     @Override
     protected CompletableFuture<Void> finish(boolean commit) {

Review Comment:
   It's required to update both internal and public javadocs within Transaction 
IgniteAbstractTransactionImpl providing the details of how 
finish/commit/rollback works on repeatable calls.



##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/ReadWriteTransactionImpl.java:
##########
@@ -126,10 +135,14 @@ protected CompletableFuture<Void> finish(boolean commit) {
                                         id()
                                 );
                             } else {
-                                return CompletableFuture.completedFuture(null);
+                                return completedFuture(null);
                             }
                         }
                 );
+
+        mainFinishFut.handle((res, e) -> finishFut.get().complete(null));

Review Comment:
   What kind of exceptions do you expect here? Is it a tmp solution until `// 
TODO: https://issues.apache.org/jira/browse/IGNITE-17688 Add proper exception 
handling.` is implemented?



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/raft/PartitionListener.java:
##########
@@ -279,12 +280,13 @@ private void handleUpdateAllCommand(UpdateAllCommand cmd, 
long commandIndex, lon
      * @param cmd Command.
      * @param commandIndex Index of the RAFT command.
      * @param commandTerm Term of the RAFT command.
+     * @return {@code true} if transaction state was changed.
      * @throws IgniteInternalException if an exception occurred during a 
transaction state change.
      */
-    private void handleFinishTxCommand(FinishTxCommand cmd, long commandIndex, 
long commandTerm) throws IgniteInternalException {
+    private boolean handleFinishTxCommand(FinishTxCommand cmd, long 
commandIndex, long commandTerm) throws IgniteInternalException {

Review Comment:
   The major one: why do you need boolean as a result value?



##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/ReadWriteTransactionImpl.java:
##########
@@ -126,10 +135,14 @@ protected CompletableFuture<Void> finish(boolean commit) {
                                         id()
                                 );
                             } else {
-                                return CompletableFuture.completedFuture(null);
+                                return completedFuture(null);
                             }
                         }
                 );
+
+        mainFinishFut.handle((res, e) -> finishFut.get().complete(null));
+
+        return mainFinishFut;

Review Comment:
   What's the point of returning mainFinishFut and not finishFut here?



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to