Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5f7e91

Browse files
knizhnikkelvich
authored andcommitted
Abort transactions if configuration is changed since transaction was prepared
1 parentb84020a commite5f7e91

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

‎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 */

‎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-
CREATEFUNCTIONmtm.get_csn(integerxid) RETURNSbigint
30+
CREATEFUNCTIONmtm.get_csn(xidinteger) RETURNSbigint
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-
CREATEFUNCTIONmtm.get_trans_by_xid(integerxid) RETURNSmtm.trans_state
54+
CREATEFUNCTIONmtm.get_trans_by_xid(xidinteger) RETURNSmtm.trans_state
5555
AS'MODULE_PATHNAME','mtm_get_trans_by_xid'
5656
LANGUAGE C;
5757

‎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_tstart=MtmGetSystemTime();
10211021
timestamp_tdeadline=start+timeout;
10221022
timestamp_tnow;
1023-
1023+
nodemask_tliveNodesMask= (((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)

[8]ページ先頭

©2009-2025 Movatter.jp