@@ -1254,6 +1254,15 @@ Mtm2PCVoting(MtmCurrentTrans* x, MtmTransState* ts)
12541254MTM_LOG3 ("%d: Result of vote: %d" ,MyProcPid ,MtmTxnStatusMnem [ts -> status ]);
12551255}
12561256
1257+ static void MtmStopTransaction (void )
1258+ {
1259+ if (MtmInsideTransaction ) {
1260+ Assert (Mtm -> nRunningTransactions > 0 );
1261+ Mtm -> nRunningTransactions -= 1 ;
1262+ MtmInsideTransaction = false;
1263+ }
1264+ }
1265+
12571266static void
12581267MtmPostPrepareTransaction (MtmCurrentTrans * x )
12591268{
@@ -1292,13 +1301,14 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
12921301}else {
12931302ts -> votingCompleted = true;
12941303}
1295- MtmUnlock ();
12961304if (x -> isTwoPhase ) {
12971305if (x -> status == TRANSACTION_STATUS_ABORTED ) {
12981306MTM_ELOG (WARNING ,"Prepare of user's 2PC transaction %s (%llu) is aborted by DTM" ,x -> gid , (long64 )x -> xid );
1299- }
1307+ }
1308+ MtmStopTransaction ();
13001309MtmResetTransaction ();
13011310}
1311+ MtmUnlock ();
13021312}
13031313if (Mtm -> inject2PCError == 3 ) {
13041314Mtm -> inject2PCError = 0 ;
@@ -1386,7 +1396,7 @@ MtmLogAbortLogicalMessage(int nodeId, char const* gid)
13861396XLogFlush (lsn );
13871397MTM_LOG1 ("MtmLogAbortLogicalMessage node=%d transaction=%s lsn=%llx" ,nodeId ,gid ,lsn );
13881398}
1389-
1399+
13901400
13911401static void
13921402MtmEndTransaction (MtmCurrentTrans * x ,bool commit )
@@ -1397,11 +1407,7 @@ MtmEndTransaction(MtmCurrentTrans* x, bool commit)
13971407
13981408MtmLock (LW_EXCLUSIVE );
13991409
1400- if (MtmInsideTransaction ) {
1401- Assert (Mtm -> nRunningTransactions > 0 );
1402- Mtm -> nRunningTransactions -= 1 ;
1403- MtmInsideTransaction = false;
1404- }
1410+ MtmStopTransaction ();
14051411
14061412if (x -> isDistributed && (x -> isPrepared || x -> isReplicated )&& !x -> isTwoPhase ) {
14071413MtmTransState * ts = NULL ;