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


##########
modules/client/src/main/java/org/apache/ignite/internal/client/tx/ClientTransaction.java:
##########
@@ -101,23 +105,13 @@ public void rollback() throws TransactionException {
     /** {@inheritDoc} */
     @Override
     public CompletableFuture<Void> rollbackAsync() {
-        setState(STATE_ROLLED_BACK);
-
-        return ch.serviceAsync(ClientOp.TX_ROLLBACK, w -> 
w.out().packLong(id), r -> null);
-    }
-
-    private void setState(int state) {
-        int oldState = this.state.compareAndExchange(STATE_OPEN, state);
-
-        if (oldState == STATE_OPEN) {
-            return;
+        if (!finishFut.compareAndSet(null, new CompletableFuture<>())) {
+            return completedFuture(null);
         }
 
-        String message = oldState == STATE_COMMITTED
-                ? "Transaction is already committed."
-                : "Transaction is already rolled back.";
+        commitState = false;
 
-        throw new TransactionException(message);
+        return ch.serviceAsync(ClientOp.TX_ROLLBACK, w -> 
w.out().packLong(id), r -> null);

Review Comment:
   fixed



##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/ReadWriteTransactionImpl.java:
##########
@@ -51,6 +53,12 @@ public class ReadWriteTransactionImpl extends 
IgniteAbstractTransactionImpl {
     /** Reference to the partition that stores the transaction state. */
     private final AtomicReference<ReplicationGroupId> commitPartitionRef = new 
AtomicReference<>();
 
+    /** The future used on repeated commit/rollback. */
+    private final AtomicReference<CompletableFuture<Void>> finishFut = new 
AtomicReference<>();
+
+    /** {@code true} if commit is started. */
+    private volatile boolean commitState;

Review Comment:
   fixed



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