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

Commit 19ac6dc

Browse files
committed
Check cluster configuration changes in wait 2PC loop
1 parent 722fd18 commit 19ac6dc

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

contrib/mmts/multimaster.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,12 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
900900
int nConfigChanges = Mtm->nConfigChanges;
901901

902902
timestamp_t start = MtmGetSystemTime();
903-
/* wait votes from all nodes */
904-
while (!ts->votingCompleted && Mtm->status == MTM_ONLINE && ts->status != TRANSACTION_STATUS_ABORTED && start + transTimeout >= MtmGetSystemTime())
903+
/* Wait votes from all nodes until: */
904+
while (!ts->votingCompleted /* all nodes voted */
905+
&& nConfigChanges == Mtm->nConfigChanges /* configarion is changed */
906+
&& Mtm->status == MTM_ONLINE /* node is not online */
907+
&& ts->status != TRANSACTION_STATUS_ABORTED /* transaction is aborted */
908+
&& start + transTimeout >= MtmGetSystemTime()) /* timeout is expired */
905909
{
906910
MtmUnlock();
907911
MTM_TXTRACE(x, "PostPrepareTransaction WaitLatch Start");
@@ -912,14 +916,13 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
912916
}
913917
MtmLock(LW_SHARED);
914918
}
915-
if (!ts->votingCompleted) {
916-
if (ts->status != TRANSACTION_STATUS_ABORTED) {
917-
MtmAbortTransaction(ts);
919+
if (ts->status != TRANSACTION_STATUS_ABORTED && (!ts->votingCompleted || nConfigChanges != Mtm->nConfigChanges)) {
920+
if (nConfigChanges != Mtm->nConfigChanges) {
921+
elog(WARNING, "Transaction %d is aborted because cluster configuration is changed during commit", x->xid);
922+
} else {
918923
elog(WARNING, "Transaction %d is aborted because of %d msec timeout expiration, prepare time %d msec", x->xid, (int)transTimeout, (int)USEC_TO_MSEC(ts->csn - x->snapshot));
919924
}
920-
} else if (nConfigChanges != Mtm->nConfigChanges) {
921925
MtmAbortTransaction(ts);
922-
elog(WARNING, "Transaction %d is aborted because cluster configuration is changed during commit", x->xid);
923926
}
924927
x->status = ts->status;
925928
MTM_LOG3("%d: Result of vote: %d", MyProcPid, ts->status);
@@ -2299,6 +2302,7 @@ void MtmReceiverStarted(int nodeId)
22992302
BIT_SET(Mtm->pglogicalNodeMask, nodeId-1);
23002303
if (BIT_CHECK(Mtm->disabledNodeMask, nodeId-1)) {
23012304
MtmEnableNode(nodeId);
2305+
MtmCheckQuorum();
23022306
}
23032307
if (++Mtm->nReceivers == Mtm->nLiveNodes-1) {
23042308
if (Mtm->status == MTM_CONNECTED) {

contrib/mmts/pglogical_receiver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ pglogical_receiver_main(Datum main_arg)
227227

228228
MtmCreateSpillDirectory(nodeId);
229229

230-
Mtm->nodes[nodeId-1].senderPid = MyProcPid;
231-
Mtm->nodes[nodeId-1].senderStartTime = MtmGetSystemTime();
230+
Mtm->nodes[nodeId-1].receiverPid = MyProcPid;
231+
Mtm->nodes[nodeId-1].receiverStartTime = MtmGetSystemTime();
232232

233233
sprintf(worker_proc, "mtm_pglogical_receiver_%d_%d", MtmNodeId, nodeId);
234234

contrib/mmts/tests2/docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ if [ "$1" = 'postgres' ]; then
8888
multimaster.conn_strings = '$CONNSTRS'
8989
multimaster.heartbeat_recv_timeout = 1000
9090
multimaster.heartbeat_send_timeout = 250
91-
multimaster.twopc_min_timeout = 40000
91+
multimaster.twopc_min_timeout = 5000
9292
EOF
9393

9494
tail -n 20 $PGDATA/postgresql.conf

0 commit comments

Comments
 (0)