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

Commit e4ceec5

Browse files
knizhnikkelvich
authored andcommitted
More correct rollback of hanged replicated transactions
1 parent c53a67c commit e4ceec5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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
}

multimaster.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ void MtmWakeUpBackend(MtmTransState* ts)
10631063
void MtmAbortTransaction(MtmTransState* ts)
10641064
{
10651065
if (ts->status != TRANSACTION_STATUS_ABORTED) {
1066-
MTM_LOG1("Rollback active transaction %d:%d", ts->gtid.node, ts->gtid.xid);
1066+
MTM_LOG1("Rollback active transaction %d:%d (local xid %d)", ts->gtid.node, ts->gtid.xid, ts->xid);
10671067
ts->status = TRANSACTION_STATUS_ABORTED;
10681068
MtmAdjustSubtransactions(ts);
10691069
Mtm->nActiveTransactions -= 1;
@@ -1387,8 +1387,8 @@ bool MtmRefreshClusterStatus(bool nowait)
13871387
MtmAbortTransaction(ts);
13881388
MtmWakeUpBackend(ts);
13891389
}
1390-
} else if (BIT_CHECK(disabled, ts->gtid.node-1)) { // coordinator of transaction is on disabled node
1391-
if (ts->status != TRANSACTION_STATUS_ABORTED) {
1390+
} else if (TransactionIdIsValid(ts->gtid.xid) && BIT_CHECK(disabled, ts->gtid.node-1)) { // coordinator of transaction is on disabled node
1391+
if (ts->gid[0] && ts->status != TRANSACTION_STATUS_ABORTED) {
13921392
MtmAbortTransaction(ts);
13931393
FinishPreparedTransaction(ts->gid, false);
13941394
}
@@ -1457,8 +1457,8 @@ void MtmOnNodeDisconnect(int nodeId)
14571457
MtmAbortTransaction(ts);
14581458
MtmWakeUpBackend(ts);
14591459
}
1460-
} else if (ts->gtid.node == nodeId) { //coordinator of transaction is on disabled node
1461-
if (ts->status != TRANSACTION_STATUS_ABORTED) {
1460+
} else if (TransactionIdIsValid(ts->gtid.xid) && ts->gtid.node == nodeId) { //coordinator of transaction is on disabled node
1461+
if (ts->gid[0] && ts->status != TRANSACTION_STATUS_ABORTED) {
14621462
MtmAbortTransaction(ts);
14631463
FinishPreparedTransaction(ts->gid, false);
14641464
}

0 commit comments

Comments
 (0)