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

Commit 23c06aa

Browse files
knizhnikkelvich
authored andcommitted
Handle PREPARE message for aborted transactions at slaves
1 parent 0e9e9ca commit 23c06aa

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

arbiter.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -904,11 +904,15 @@ static void MtmTransReceiver(Datum arg)
904904
} else {
905905
switch (msg->code) {
906906
case MSG_PREPARE:
907-
Assert(ts->status == TRANSACTION_STATUS_IN_PROGRESS);
908-
ts->status = TRANSACTION_STATUS_UNKNOWN;
909-
ts->csn = MtmAssignCSN();
910-
MtmAdjustSubtransactions(ts);
911-
MtmSendNotificationMessage(ts, MSG_PREPARED);
907+
if (ts->status == TRANSACTION_STATUS_IN_PROGRESS) {
908+
ts->status = TRANSACTION_STATUS_UNKNOWN;
909+
ts->csn = MtmAssignCSN();
910+
MtmAdjustSubtransactions(ts);
911+
MtmSendNotificationMessage(ts, MSG_PREPARED);
912+
} else {
913+
Assert(ts->status == TRANSACTION_STATUS_ABORTED);
914+
MtmSendNotificationMessage(ts, MSG_ABORTED);
915+
}
912916
break;
913917
default:
914918
Assert(false);

multimaster.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ int MtmReplicationNodeId;
195195
int MtmArbiterPort;
196196
int MtmConnectTimeout;
197197
int MtmReconnectTimeout;
198-
int MtmRaftPollDelay;
199198
int MtmNodeDisableDelay;
200199
int MtmTransSpillThreshold;
201200
int MtmMaxNodes;
@@ -736,7 +735,7 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
736735

737736
if (Mtm->disabledNodeMask != 0) {
738737
timestamp_t now = MtmGetSystemTime();
739-
if (Mtm->lastClusterStatusUpdate + MSEC_TO_USEC(MtmRaftPollDelay) < now) {
738+
if (Mtm->lastClusterStatusUpdate + MSEC_TO_USEC(MtmHeartbeatRecvTimeout) < now) {
740739
Mtm->lastClusterStatusUpdate = now;
741740
MtmRefreshClusterStatus(true);
742741
}
@@ -1438,7 +1437,7 @@ void MtmOnNodeDisconnect(int nodeId)
14381437

14391438
RaftableSet(psprintf("node-mask-%d", MtmNodeId), &Mtm->connectivityMask, sizeof Mtm->connectivityMask, true); /* false); -- TODO: raftable is hanged with nowait=true */
14401439

1441-
MtmSleep(MSEC_TO_USEC(MtmRaftPollDelay));
1440+
MtmSleep(MSEC_TO_USEC(MtmHeartbeatSendTimeout));
14421441

14431442
if (!MtmUseRaftable)
14441443
{
@@ -2059,22 +2058,6 @@ _PG_init(void)
20592058
NULL
20602059
);
20612060

2062-
DefineCustomIntVariable(
2063-
"multimaster.raft_poll_delay",
2064-
"Multimaster delay of polling cluster state from Raftable after updating local node status",
2065-
"Timeout in milliseconds before polling state of nodes",
2066-
&MtmRaftPollDelay,
2067-
1000,
2068-
1,
2069-
INT_MAX,
2070-
PGC_BACKEND,
2071-
0,
2072-
NULL,
2073-
NULL,
2074-
NULL
2075-
);
2076-
2077-
20782061
MtmSplitConnStrs();
20792062
MtmStartReceivers();
20802063

0 commit comments

Comments
 (0)