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

Commit d565586

Browse files
knizhnikkelvich
authored andcommitted
Check cluster configuration changes in wait 2PC loop
1 parent 170469d commit d565586

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

multimaster.c

+11-7
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,12 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
909909
int nConfigChanges = Mtm->nConfigChanges;
910910

911911
timestamp_t start = MtmGetSystemTime();
912-
/* wait votes from all nodes */
913-
while (!ts->votingCompleted && Mtm->status == MTM_ONLINE && ts->status != TRANSACTION_STATUS_ABORTED && start + transTimeout >= MtmGetSystemTime())
912+
/* Wait votes from all nodes until: */
913+
while (!ts->votingCompleted /* all nodes voted */
914+
&& nConfigChanges == Mtm->nConfigChanges /* configarion is changed */
915+
&& Mtm->status == MTM_ONLINE /* node is not online */
916+
&& ts->status != TRANSACTION_STATUS_ABORTED /* transaction is aborted */
917+
&& start + transTimeout >= MtmGetSystemTime()) /* timeout is expired */
914918
{
915919
MtmUnlock();
916920
MTM_TXTRACE(x, "PostPrepareTransaction WaitLatch Start");
@@ -921,14 +925,13 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
921925
}
922926
MtmLock(LW_SHARED);
923927
}
924-
if (!ts->votingCompleted) {
925-
if (ts->status != TRANSACTION_STATUS_ABORTED) {
926-
MtmAbortTransaction(ts);
928+
if (ts->status != TRANSACTION_STATUS_ABORTED && (!ts->votingCompleted || nConfigChanges != Mtm->nConfigChanges)) {
929+
if (nConfigChanges != Mtm->nConfigChanges) {
930+
elog(WARNING, "Transaction %d is aborted because cluster configuration is changed during commit", x->xid);
931+
} else {
927932
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));
928933
}
929-
} else if (nConfigChanges != Mtm->nConfigChanges) {
930934
MtmAbortTransaction(ts);
931-
elog(WARNING, "Transaction %d is aborted because cluster configuration is changed during commit", x->xid);
932935
}
933936
x->status = ts->status;
934937
MTM_LOG3("%d: Result of vote: %d", MyProcPid, ts->status);
@@ -2308,6 +2311,7 @@ void MtmReceiverStarted(int nodeId)
23082311
BIT_SET(Mtm->pglogicalNodeMask, nodeId-1);
23092312
if (BIT_CHECK(Mtm->disabledNodeMask, nodeId-1)) {
23102313
MtmEnableNode(nodeId);
2314+
MtmCheckQuorum();
23112315
}
23122316
if (++Mtm->nReceivers == Mtm->nLiveNodes-1) {
23132317
if (Mtm->status == MTM_CONNECTED) {

pglogical_receiver.c

+2-2
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

tests2/docker-entrypoint.sh

+1-1
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)