@@ -695,20 +695,18 @@ MtmCreateTransState(MtmCurrentTrans* x)
695
695
{
696
696
bool found ;
697
697
MtmTransState * ts = hash_search (MtmXid2State , & x -> xid , HASH_ENTER , & found );
698
- if (!found ) {
699
- ts -> status = TRANSACTION_STATUS_IN_PROGRESS ;
700
- ts -> snapshot = x -> snapshot ;
701
- ts -> isLocal = true;
702
- if (TransactionIdIsValid (x -> gtid .xid )) {
703
- Assert (x -> gtid .node != MtmNodeId );
704
- ts -> gtid = x -> gtid ;
705
- strcpy (ts -> gid , x -> gid );
706
- } else {
707
- /* I am coordinator of transaction */
708
- ts -> gtid .xid = x -> xid ;
709
- ts -> gtid .node = MtmNodeId ;
710
- ts -> gid [0 ] = '\0' ;
711
- }
698
+ ts -> status = TRANSACTION_STATUS_IN_PROGRESS ;
699
+ ts -> snapshot = x -> snapshot ;
700
+ ts -> isLocal = true;
701
+ if (TransactionIdIsValid (x -> gtid .xid )) {
702
+ Assert (x -> gtid .node != MtmNodeId );
703
+ ts -> gtid = x -> gtid ;
704
+ strcpy (ts -> gid , x -> gid );
705
+ } else {
706
+ /* I am coordinator of transaction */
707
+ ts -> gtid .xid = x -> xid ;
708
+ ts -> gtid .node = MtmNodeId ;
709
+ ts -> gid [0 ] = '\0' ;
712
710
}
713
711
return ts ;
714
712
}
@@ -854,11 +852,11 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
854
852
if (!ts -> votingCompleted ) {
855
853
if (ts -> status != TRANSACTION_STATUS_ABORTED ) {
856
854
MtmAbortTransaction (ts );
857
- elog (WARNING , "Transaction is aborted because of %d msec timeout expiration, prepare time %d msec" , (int )transTimeout , (int )USEC_TO_MSEC (ts -> csn - x -> snapshot ));
855
+ elog (WARNING , "Transaction %d is aborted because of %d msec timeout expiration, prepare time %d msec" , x -> xid , (int )transTimeout , (int )USEC_TO_MSEC (ts -> csn - x -> snapshot ));
858
856
}
859
857
} else if (nConfigChanges != Mtm -> nConfigChanges ) {
860
858
MtmAbortTransaction (ts );
861
- elog (WARNING , "Transaction is aborted because cluster configuration is changed during commit" );
859
+ elog (WARNING , "Transaction %d is aborted because cluster configuration is changed during commit" , x -> xid );
862
860
}
863
861
x -> status = ts -> status ;
864
862
MTM_LOG3 ("%d: Result of vote: %d" , MyProcPid , ts -> status );
@@ -880,9 +878,12 @@ MtmAbortPreparedTransaction(MtmCurrentTrans* x)
880
878
MtmLock (LW_EXCLUSIVE );
881
879
tm = (MtmTransMap * )hash_search (MtmGid2State , x -> gid , HASH_REMOVE , NULL );
882
880
Assert (tm != NULL );
881
+ MTM_LOG1 ("Abort prepared transaction %d with gid='%s' is already aborted" , x -> xid , x -> gid );
883
882
MtmAbortTransaction (tm -> state );
884
883
MtmUnlock ();
885
884
x -> status = TRANSACTION_STATUS_ABORTED ;
885
+ } else {
886
+ MTM_LOG1 ("Transaction %d with gid='%s' is already aborted" , x -> xid , x -> gid );
886
887
}
887
888
}
888
889
@@ -918,6 +919,7 @@ MtmEndTransaction(MtmCurrentTrans* x, bool commit)
918
919
Assert (Mtm -> nActiveTransactions != 0 );
919
920
Mtm -> nActiveTransactions -= 1 ;
920
921
} else {
922
+ MTM_LOG1 ("%d: abort transaction %d gid='%s' is called from MtmEndTransaction" , MyProcPid , x -> xid , x -> gid );
921
923
MtmAbortTransaction (ts );
922
924
}
923
925
}
@@ -998,7 +1000,7 @@ void MtmJoinTransaction(GlobalTransactionId* gtid, csn_t globalSnapshot)
998
1000
999
1001
void MtmSetCurrentTransactionGID (char const * gid )
1000
1002
{
1001
- MTM_LOG3 ("Set current transaction GID %s" , gid );
1003
+ MTM_LOG3 ("Set current transaction xid=%d GID %s" , MtmTx . xid , gid );
1002
1004
strcpy (MtmTx .gid , gid );
1003
1005
MtmTx .isDistributed = true;
1004
1006
MtmTx .isReplicated = true;
@@ -1383,15 +1385,21 @@ bool MtmRefreshClusterStatus(bool nowait)
1383
1385
MtmCheckQuorum ();
1384
1386
/* Interrupt voting for active transaction and abort them */
1385
1387
for (ts = Mtm -> transListHead ; ts != NULL ; ts = ts -> next ) {
1388
+ MTM_LOG3 ("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d" ,
1389
+ ts -> gid , ts -> gtid .node , ts -> xid , ts -> status , ts -> gtid .xid );
1386
1390
if (MtmIsCoordinator (ts )) {
1387
1391
if (!ts -> votingCompleted && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1388
1392
MtmAbortTransaction (ts );
1389
1393
MtmWakeUpBackend (ts );
1390
1394
}
1391
1395
} else if (TransactionIdIsValid (ts -> gtid .xid ) && BIT_CHECK (disabled , ts -> gtid .node - 1 )) { // coordinator of transaction is on disabled node
1392
- if (ts -> gid [0 ] && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1393
- MtmAbortTransaction (ts );
1394
- FinishPreparedTransaction (ts -> gid , false);
1396
+ if (ts -> gid [0 ]) {
1397
+ if (ts -> status == TRANSACTION_STATUS_UNKNOWN || ts -> status == TRANSACTION_STATUS_IN_PROGRESS ) {
1398
+ MTM_LOG1 ("%d: Abort trasaction %s because its coordinator is at disabled node %d" , MyProcPid , ts -> gid , ts -> gtid .node );
1399
+ MtmAbortTransaction (ts );
1400
+ MtmTx .status = TRANSACTION_STATUS_ABORTED ; /* prevent recursive invocation of MtmAbortPreparedTransaction */
1401
+ FinishPreparedTransaction (ts -> gid , false);
1402
+ }
1395
1403
}
1396
1404
}
1397
1405
}
@@ -1461,6 +1469,7 @@ void MtmOnNodeDisconnect(int nodeId)
1461
1469
} else if (TransactionIdIsValid (ts -> gtid .xid ) && ts -> gtid .node == nodeId ) { //coordinator of transaction is on disabled node
1462
1470
if (ts -> gid [0 ] && ts -> status != TRANSACTION_STATUS_ABORTED ) {
1463
1471
MtmAbortTransaction (ts );
1472
+ MtmTx .status = TRANSACTION_STATUS_ABORTED ; /* prevent recursive invocation of MtmAbortPreparedTransaction */
1464
1473
FinishPreparedTransaction (ts -> gid , false);
1465
1474
}
1466
1475
}
0 commit comments