denis-chudov commented on code in PR #7482:
URL: https://github.com/apache/ignite-3/pull/7482#discussion_r2882915075


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -3822,6 +3842,49 @@ private CompletableFuture<?> 
processOperationRequestWithTxOperationManagementLog
         }
     }
 
+    private void storeFailureInTxMeta(ReplicaRequest request, Throwable 
throwable) {
+        if (!(request instanceof ReadWriteReplicaRequest)) {
+            return;
+        }
+
+        UUID txId = ((ReadWriteReplicaRequest) request).transactionId();
+        Throwable toStore = unwrapRootCause(throwable);
+
+        txManager.enrichTxMeta(txId, old -> {
+            if (old == null || old.lastException() != null) {
+                return old;
+            }
+
+            return old.mutate()
+                    .lastException(toStore)
+                    .build();
+        });
+    }
+
+    private @Nullable TransactionException 
transactionAlreadyFinishedException(ReplicaRequest request) {
+        if (!(request instanceof ReadWriteReplicaRequest)) {
+            return null;
+        }
+
+        UUID txId = ((ReadWriteReplicaRequest) request).transactionId();
+        TxStateMeta txStateMeta = txManager.stateMeta(txId);
+
+        if (txStateMeta == null || !(isFinalState(txStateMeta.txState()) || 
txStateMeta.txState() == FINISHING)) {
+            return null;
+        }
+
+        TxState txState = txStateMeta.txState();
+        boolean isFinishedDueToTimeout = txStateMeta.isFinishedDueToTimeout() 
!= null && txStateMeta.isFinishedDueToTimeout();
+        Throwable cause = txStateMeta.lastException();
+
+        return new TransactionException(
+                isFinishedDueToTimeout ? TX_ALREADY_FINISHED_WITH_TIMEOUT_ERR 
: TX_ALREADY_FINISHED_ERR,
+                format((isFinishedDueToTimeout ? 
TX_ALREADY_FINISHED_DUE_TO_TIMEOUT : TX_ALREADY_FINISHED)

Review Comment:
   In this and similar cases, for example 
`InternalTableImpl#checkTransactionFinishStarted` I think there should be 
separate error code for "transaction finished due to exception".



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