Skip to content

Commit 35e1163

Browse files
knizhnikkelvich
authored andcommitted
Wakeup hanged 2PC transactions
1 parent aac8d16 commit 35e1163

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

multimaster.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
835835
MtmUnlock();
836836
MtmResetTransaction(x);
837837
} else {
838-
time_t transTimeout = Max(MSEC_TO_USEC(Mtm2PCMinTimeout), (ts->csn - ts->snapshot)*Mtm2PCPrepareRatio/100); /* usec->msec and percents */
838+
time_t transTimeout = Max(MSEC_TO_USEC(Mtm2PCMinTimeout), (ts->csn - ts->snapshot)*Mtm2PCPrepareRatio/100);
839839
int result = 0;
840840
int nConfigChanges = Mtm->nConfigChanges;
841841

@@ -1343,6 +1343,7 @@ bool MtmRefreshClusterStatus(bool nowait)
13431343
nodemask_t mask, clique;
13441344
nodemask_t matrix[MAX_NODES];
13451345
int clique_size;
1346+
MtmTransState *ts;
13461347
int i;
13471348

13481349
if (!MtmUseRaftable || !MtmBuildConnectivityMatrix(matrix, nowait)) {
@@ -1378,6 +1379,16 @@ bool MtmRefreshClusterStatus(bool nowait)
13781379
}
13791380
}
13801381
MtmCheckQuorum();
1382+
/* Interrupt voting for active transaction and abort them */
1383+
for (ts = Mtm->transListHead; ts != NULL; ts = ts->next) {
1384+
if (!ts->votingCompleted) {
1385+
if (ts->status != TRANSACTION_STATUS_ABORTED) {
1386+
MTM_LOG1("Rollback active transaction %d:%d", ts->gtid.node, ts->gtid.xid);
1387+
MtmAbortTransaction(ts);
1388+
}
1389+
MtmWakeUpBackend(ts);
1390+
}
1391+
}
13811392
MtmUnlock();
13821393
if (BIT_CHECK(Mtm->disabledNodeMask, MtmNodeId-1)) {
13831394
if (Mtm->status == MTM_ONLINE) {

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