Skip to content

Commit 7cf14d5

Browse files
knizhnikkelvich
authored andcommitted
Correctly update nRunningTransactions for user's 2PC transactions
1 parent 3586931 commit 7cf14d5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

multimaster.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
12581267
static void
12591268
MtmPostPrepareTransaction(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

13921402
static void
13931403
MtmEndTransaction(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

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