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