@@ -1255,6 +1255,15 @@ Mtm2PCVoting(MtmCurrentTrans* x, MtmTransState* ts)
12551255 MTM_LOG3 ("%d: Result of vote: %d" , MyProcPid , MtmTxnStatusMnem [ts -> status ]);
12561256}
12571257
1258+ static void MtmStopTransaction (void )
1259+ {
1260+ if (MtmInsideTransaction ) {
1261+ Assert (Mtm -> nRunningTransactions > 0 );
1262+ Mtm -> nRunningTransactions -= 1 ;
1263+ MtmInsideTransaction = false;
1264+ }
1265+ }
1266+
12581267static void
12591268MtmPostPrepareTransaction (MtmCurrentTrans * x )
12601269{
@@ -1293,13 +1302,14 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
12931302 } else {
12941303 ts -> votingCompleted = true;
12951304 }
1296- MtmUnlock ();
12971305 if (x -> isTwoPhase ) {
12981306 if (x -> status == TRANSACTION_STATUS_ABORTED ) {
12991307 MTM_ELOG (WARNING , "Prepare of user's 2PC transaction %s (%llu) is aborted by DTM" , x -> gid , (long64 )x -> xid );
1300- }
1308+ }
1309+ MtmStopTransaction ();
13011310 MtmResetTransaction ();
13021311 }
1312+ MtmUnlock ();
13031313 }
13041314 if (Mtm -> inject2PCError == 3 ) {
13051315 Mtm -> inject2PCError = 0 ;
@@ -1387,7 +1397,7 @@ MtmLogAbortLogicalMessage(int nodeId, char const* gid)
13871397 XLogFlush (lsn );
13881398 MTM_LOG1 ("MtmLogAbortLogicalMessage node=%d transaction=%s lsn=%llx" , nodeId , gid , lsn );
13891399}
1390-
1400+
13911401
13921402static void
13931403MtmEndTransaction (MtmCurrentTrans * x , bool commit )
@@ -1398,11 +1408,7 @@ MtmEndTransaction(MtmCurrentTrans* x, bool commit)
13981408
13991409 MtmLock (LW_EXCLUSIVE );
14001410
1401- if (MtmInsideTransaction ) {
1402- Assert (Mtm -> nRunningTransactions > 0 );
1403- Mtm -> nRunningTransactions -= 1 ;
1404- MtmInsideTransaction = false;
1405- }
1411+ MtmStopTransaction ();
14061412
14071413 if (x -> isDistributed && (x -> isPrepared || x -> isReplicated ) && !x -> isTwoPhase ) {
14081414 MtmTransState * ts = NULL ;
0 commit comments