Skip to content

Commit ed87b14

Browse files
committed
More correct rollback of hanged replicated transactions
1 parent d5facb5 commit ed87b14

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

contrib/mmts/arbiter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static void MtmSendHeartbeat()
347347
{
348348
size_t rc = send(sockets[i], &msg, sizeof(msg), 0);
349349
if ((size_t)rc != sizeof(msg)) {
350-
elog(LOG, "Failed to send heartbeat to node %d: %d", i, errno);
350+
elog(LOG, "Failed to send heartbeat to node %d: %d", i+1, errno);
351351
}
352352
}
353353
}

contrib/mmts/multimaster.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ void MtmWakeUpBackend(MtmTransState* ts)
10641064
void MtmAbortTransaction(MtmTransState* ts)
10651065
{
10661066
if (ts->status != TRANSACTION_STATUS_ABORTED) {
1067-
MTM_LOG1("Rollback active transaction %d:%d", ts->gtid.node, ts->gtid.xid);
1067+
MTM_LOG1("Rollback active transaction %d:%d (local xid %d)", ts->gtid.node, ts->gtid.xid, ts->xid);
10681068
ts->status = TRANSACTION_STATUS_ABORTED;
10691069
MtmAdjustSubtransactions(ts);
10701070
Mtm->nActiveTransactions -= 1;
@@ -1388,9 +1388,8 @@ bool MtmRefreshClusterStatus(bool nowait)
13881388
MtmAbortTransaction(ts);
13891389
MtmWakeUpBackend(ts);
13901390
}
1391-
} else if (BIT_CHECK(disabled, ts->gtid.node-1)) { // coordinator of transaction is on disabled node
1392-
if (ts->status != TRANSACTION_STATUS_ABORTED) {
1393-
MTM_LOG1("1) Rollback active transaction %d:%d:%d", ts->gtid.node, ts->gtid.xid, ts->xid);
1391+
} else if (TransactionIdIsValid(ts->gtid.xid) && BIT_CHECK(disabled, ts->gtid.node-1)) { // coordinator of transaction is on disabled node
1392+
if (ts->gid[0] && ts->status != TRANSACTION_STATUS_ABORTED) {
13941393
MtmAbortTransaction(ts);
13951394
FinishPreparedTransaction(ts->gid, false);
13961395
}
@@ -1459,9 +1458,8 @@ void MtmOnNodeDisconnect(int nodeId)
14591458
MtmAbortTransaction(ts);
14601459
MtmWakeUpBackend(ts);
14611460
}
1462-
} else if (ts->gtid.node == nodeId) { //coordinator of transaction is on disabled node
1463-
if (ts->status != TRANSACTION_STATUS_ABORTED) {
1464-
MTM_LOG1("2) Rollback active transaction %d:%d", ts->gtid.node, ts->gtid.xid);
1461+
} else if (TransactionIdIsValid(ts->gtid.xid) && ts->gtid.node == nodeId) { //coordinator of transaction is on disabled node
1462+
if (ts->gid[0] && ts->status != TRANSACTION_STATUS_ABORTED) {
14651463
MtmAbortTransaction(ts);
14661464
FinishPreparedTransaction(ts->gid, false);
14671465
}

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