Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit db23ecf

Browse files
committed
Wakeup hanged 2PC transactions
1 parent bfc9f9a commit db23ecf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

contrib/mmts/multimaster.c

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

@@ -1344,6 +1344,7 @@ bool MtmRefreshClusterStatus(bool nowait)
13441344
nodemask_t mask, clique;
13451345
nodemask_t matrix[MAX_NODES];
13461346
int clique_size;
1347+
MtmTransState *ts;
13471348
int i;
13481349

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

0 commit comments

Comments
 (0)