@@ -854,6 +854,7 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
854
854
MtmTransState * ts ;
855
855
MtmTransMap * tm ;
856
856
TransactionId * subxids ;
857
+ bool found ;
857
858
MTM_TXTRACE (x , "PrePrepareTransaction Start" );
858
859
859
860
if (!x -> isDistributed ) {
@@ -869,7 +870,7 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
869
870
870
871
if (!IsBackgroundWorker && Mtm -> status != MTM_ONLINE ) {
871
872
/* Do not take in account bg-workers which are performing recovery */
872
- elog (ERROR , "Abort current transaction because this cluster node is in %s status" , MtmNodeStatusMnem [Mtm -> status ]);
873
+ elog (ERROR , "Abort transaction %s (%llu) because this cluster node is in %s status" , x -> gid , ( long64 ) x -> xid , MtmNodeStatusMnem [Mtm -> status ]);
873
874
}
874
875
if (TransactionIdIsValid (x -> gtid .xid ) && BIT_CHECK (Mtm -> disabledNodeMask , x -> gtid .node - 1 )) {
875
876
/* Coordinator of transaction is disabled: just abort transaction without any further steps */
@@ -878,6 +879,14 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
878
879
879
880
MtmLock (LW_EXCLUSIVE );
880
881
882
+ Assert (* x -> gid != '\0' );
883
+ tm = (MtmTransMap * )hash_search (MtmGid2State , x -> gid , HASH_ENTER , & found );
884
+ if (found && tm -> status != TRANSACTION_STATUS_IN_PROGRESS ) {
885
+ Assert (tm -> status == TRANSACTION_STATUS_ABORTED );
886
+ MtmUnlock ();
887
+ elog (ERROR , "Skip already aborted transaction %s (%llu) from node %d" , x -> gid , (long64 )x -> xid , x -> gtid .node );
888
+ }
889
+
881
890
ts = MtmCreateTransState (x );
882
891
/*
883
892
* Invalid CSN prevent replication of transaction by logical replication
@@ -898,8 +907,6 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
898
907
x -> isPrepared = true;
899
908
x -> csn = ts -> csn ;
900
909
901
- Assert (* x -> gid != '\0' );
902
- tm = (MtmTransMap * )hash_search (MtmGid2State , x -> gid , HASH_ENTER , NULL );
903
910
tm -> state = ts ;
904
911
tm -> status = TRANSACTION_STATUS_IN_PROGRESS ;
905
912
MTM_LOG2 ("Prepare transaction %s" , x -> gid );
0 commit comments