Skip to content

Commit df1db59

Browse files
committed
Correctly update nRunningTransactions for user's 2PC transactions
1 parent ab68613 commit df1db59

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

contrib/mmts/multimaster.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,15 @@ Mtm2PCVoting(MtmCurrentTrans* x, MtmTransState* ts)
12541254
MTM_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+
12571266
static void
12581267
MtmPostPrepareTransaction(MtmCurrentTrans* x)
12591268
{
@@ -1292,13 +1301,14 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
12921301
} else {
12931302
ts->votingCompleted = true;
12941303
}
1295-
MtmUnlock();
12961304
if (x->isTwoPhase) {
12971305
if (x->status == TRANSACTION_STATUS_ABORTED) {
12981306
MTM_ELOG(WARNING, "Prepare of user's 2PC transaction %s (%llu) is aborted by DTM", x->gid, (long64)x->xid);
1299-
}
1307+
}
1308+
MtmStopTransaction();
13001309
MtmResetTransaction();
13011310
}
1311+
MtmUnlock();
13021312
}
13031313
if (Mtm->inject2PCError == 3) {
13041314
Mtm->inject2PCError = 0;
@@ -1386,7 +1396,7 @@ MtmLogAbortLogicalMessage(int nodeId, char const* gid)
13861396
XLogFlush(lsn);
13871397
MTM_LOG1("MtmLogAbortLogicalMessage node=%d transaction=%s lsn=%llx", nodeId, gid, lsn);
13881398
}
1389-
1399+
13901400

13911401
static void
13921402
MtmEndTransaction(MtmCurrentTrans* x, bool commit)
@@ -1397,11 +1407,7 @@ MtmEndTransaction(MtmCurrentTrans* x, bool commit)
13971407

13981408
MtmLock(LW_EXCLUSIVE);
13991409

1400-
if (MtmInsideTransaction) {
1401-
Assert(Mtm->nRunningTransactions > 0);
1402-
Mtm->nRunningTransactions -= 1;
1403-
MtmInsideTransaction = false;
1404-
}
1410+
MtmStopTransaction();
14051411

14061412
if (x->isDistributed && (x->isPrepared || x->isReplicated) && !x->isTwoPhase) {
14071413
MtmTransState* ts = NULL;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy