@@ -1254,6 +1254,15 @@ Mtm2PCVoting(MtmCurrentTrans* x, MtmTransState* ts)
1254
1254
MTM_LOG3 ("%d: Result of vote: %d" , MyProcPid , MtmTxnStatusMnem [ts -> status ]);
1255
1255
}
1256
1256
1257
+ static void MtmStopTransaction (void )
1258
+ {
1259
+ if (MtmInsideTransaction ) {
1260
+ Assert (Mtm -> nRunningTransactions > 0 );
1261
+ Mtm -> nRunningTransactions -= 1 ;
1262
+ MtmInsideTransaction = false;
1263
+ }
1264
+ }
1265
+
1257
1266
static void
1258
1267
MtmPostPrepareTransaction (MtmCurrentTrans * x )
1259
1268
{
@@ -1292,13 +1301,14 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
1292
1301
} else {
1293
1302
ts -> votingCompleted = true;
1294
1303
}
1295
- MtmUnlock ();
1296
1304
if (x -> isTwoPhase ) {
1297
1305
if (x -> status == TRANSACTION_STATUS_ABORTED ) {
1298
1306
MTM_ELOG (WARNING , "Prepare of user's 2PC transaction %s (%llu) is aborted by DTM" , x -> gid , (long64 )x -> xid );
1299
- }
1307
+ }
1308
+ MtmStopTransaction ();
1300
1309
MtmResetTransaction ();
1301
1310
}
1311
+ MtmUnlock ();
1302
1312
}
1303
1313
if (Mtm -> inject2PCError == 3 ) {
1304
1314
Mtm -> inject2PCError = 0 ;
@@ -1386,7 +1396,7 @@ MtmLogAbortLogicalMessage(int nodeId, char const* gid)
1386
1396
XLogFlush (lsn );
1387
1397
MTM_LOG1 ("MtmLogAbortLogicalMessage node=%d transaction=%s lsn=%llx" , nodeId , gid , lsn );
1388
1398
}
1389
-
1399
+
1390
1400
1391
1401
static void
1392
1402
MtmEndTransaction (MtmCurrentTrans * x , bool commit )
@@ -1397,11 +1407,7 @@ MtmEndTransaction(MtmCurrentTrans* x, bool commit)
1397
1407
1398
1408
MtmLock (LW_EXCLUSIVE );
1399
1409
1400
- if (MtmInsideTransaction ) {
1401
- Assert (Mtm -> nRunningTransactions > 0 );
1402
- Mtm -> nRunningTransactions -= 1 ;
1403
- MtmInsideTransaction = false;
1404
- }
1410
+ MtmStopTransaction ();
1405
1411
1406
1412
if (x -> isDistributed && (x -> isPrepared || x -> isReplicated ) && !x -> isTwoPhase ) {
1407
1413
MtmTransState * ts = NULL ;
0 commit comments