Skip to content

Commit 7032173

Browse files
committed
Abort transactions if configuration is changed since transaction was prepared
1 parent a9c1f86 commit 7032173

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

contrib/mmts/arbiter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ static void MtmSender(Datum arg)
764764
}
765765
}
766766
CHECK_FOR_INTERRUPTS();
767+
MtmCheckHeartbeat();
767768
}
768769
elog(LOG, "Stop arbiter sender %d", MyProcPid);
769770
proc_exit(1); /* force restart of this bgwroker */

contrib/mmts/multimaster--1.0.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ CREATE FUNCTION mtm.get_snapshot() RETURNS bigint
2727
AS 'MODULE_PATHNAME','mtm_get_snapshot'
2828
LANGUAGE C;
2929

30-
CREATE FUNCTION mtm.get_csn(integer xid) RETURNS bigint
30+
CREATE FUNCTION mtm.get_csn(xid integer) RETURNS bigint
3131
AS 'MODULE_PATHNAME','mtm_get_csn'
3232
LANGUAGE C;
3333

@@ -51,7 +51,7 @@ CREATE FUNCTION mtm.get_trans_by_gid(git text) RETURNS mtm.trans_state
5151
AS 'MODULE_PATHNAME','mtm_get_trans_by_gid'
5252
LANGUAGE C;
5353

54-
CREATE FUNCTION mtm.get_trans_by_xid(integer xid) RETURNS mtm.trans_state
54+
CREATE FUNCTION mtm.get_trans_by_xid(xid integer) RETURNS mtm.trans_state
5555
AS 'MODULE_PATHNAME','mtm_get_trans_by_xid'
5656
LANGUAGE C;
5757

contrib/mmts/multimaster.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,9 +1020,19 @@ Mtm2PCVoting(MtmCurrentTrans* x, MtmTransState* ts)
10201020
timestamp_t start = MtmGetSystemTime();
10211021
timestamp_t deadline = start + timeout;
10221022
timestamp_t now;
1023-
1023+
nodemask_t liveNodesMask = (((nodemask_t)1 << Mtm->nAllNodes) - 1) & ~Mtm->disabledNodeMask & ~((nodemask_t)1 << (MtmNodeId-1));
1024+
10241025
Assert(ts->csn > ts->snapshot);
10251026

1027+
if (ts->participantsMask != liveNodesMask)
1028+
{
1029+
elog(WARNING, "Abort transaction %d (%s) because cluster configuration is changed from %lx to %lx since transaction start",
1030+
ts->xid, ts->gid, ts->participantsMask, liveNodesMask);
1031+
MtmAbortTransaction(ts);
1032+
x->status = TRANSACTION_STATUS_ABORTED;
1033+
return;
1034+
}
1035+
10261036
/* Wait votes from all nodes until: */
10271037
while (!MtmVotingCompleted(ts)
10281038
&& (ts->isPrepared || nConfigChanges == Mtm->nConfigChanges))
@@ -1534,11 +1544,13 @@ XidStatus MtmExchangeGlobalTransactionStatus(char const* gid, XidStatus new_stat
15341544
}
15351545
if (tm->state != NULL && old_status == TRANSACTION_STATUS_IN_PROGRESS) {
15361546
/* Return UNKNOWN to mark that transaction was prepared */
1537-
MTM_LOG1("Change status of in-progress transaction %s to %s", gid, MtmTxtStatusMnem[new_status]);
1547+
if (new_status != TRANSACTION_STATUS_UNKNOWN) {
1548+
MTM_LOG1("Change status of in-progress transaction %s to %s", gid, MtmTxnStatusMnem[new_status]);
1549+
}
15381550
old_status = TRANSACTION_STATUS_UNKNOWN;
15391551
}
15401552
} else {
1541-
MTM_LOG1("Set status of unknown transaction %s to %s", gid, MtmTxtStatusMnem[new_status]);
1553+
MTM_LOG2("Set status of unknown transaction %s to %s", gid, MtmTxnStatusMnem[new_status]);
15421554
tm->state = NULL;
15431555
tm->status = new_status;
15441556
}

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