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


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -795,28 +813,50 @@ private CompletableFuture<TransactionMeta> 
processTxStateCommitPartitionRequest(
      * @param txStateMeta Transaction meta.
      * @return Tx recovery future, or completed future if the recovery isn't 
needed, or failed future if the recovery is not possible.
      */
-    private CompletableFuture<TransactionMeta> 
triggerTxRecoveryOnTxStateResolutionIfNeeded(UUID txId, @Nullable TxStateMeta 
txStateMeta) {
-        assert txStateMeta == null || !isFinalState(txStateMeta.txState()) : 
"Unexpected transaction state: " + txStateMeta;
+    private CompletableFuture<TransactionMeta> 
triggerTxRecoveryOnTxStateResolutionIfNeeded(
+            UUID txId,
+            @Nullable TxStateMeta txStateMeta
+    ) {
+        // The state is either null or PENDING or ABANDONED, other states have 
been filtered out previously.
+        assert txStateMeta == null || txStateMeta.txState() == PENDING || 
txStateMeta.txState() == ABANDONED
+                : "Unexpected transaction state: " + txStateMeta;
 
         TxMeta txMeta = txStateStorage.get(txId);
 
         if (txMeta == null) {
             // This means the transaction is pending and we should trigger the 
recovery if there is no tx coordinator in topology.
             if (txStateMeta == null
                     || txStateMeta.txState() == ABANDONED
+                    || txStateMeta.txCoordinatorId() == null
                     || 
clusterNodeResolver.getById(txStateMeta.txCoordinatorId()) == null) {
                 // This means that primary replica for commit partition has 
changed, since the local node doesn't have the volatile tx
                 // state; and there is no final tx state in txStateStorage, or 
the tx coordinator left the cluster. But we can assume
                 // that as the coordinator (or information about it) is 
missing, there is  no need to wait a finish request from
                 // tx coordinator, the transaction can't be committed at all.
-                return triggerTxRecovery(txId);
+                return triggerTxRecovery(txId, localNode.id())
+                        .handle((v, ex) -> {
+                            TransactionMeta transactionMeta = 
txManager.stateMeta(txId);
+
+                            assert transactionMeta != null;
+
+                            if (transactionMeta.txState() == FINISHING) {
+                                return ((TxStateMetaFinishing) 
transactionMeta).txFinishFuture();
+                            }
+
+                            assert transactionMeta.txState() == ABORTED;

Review Comment:
   removed all checks here - they are no longer required.



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