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

Commit 526109f

Browse files
committed
move cluster state changing function to separate module
1 parent 8b99228 commit 526109f

File tree

9 files changed

+374
-241
lines changed

9 files changed

+374
-241
lines changed

contrib/mmts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
EXTENSION = multimaster
33
DATA = multimaster--1.0.sql
4-
OBJS = multimaster.o arbiter.o bytebuf.o bgwpool.o pglogical_output.o pglogical_proto.o pglogical_receiver.o pglogical_apply.o pglogical_hooks.o pglogical_config.o pglogical_relid_map.o ddd.o bkb.o spill.o referee.o
4+
OBJS = multimaster.o arbiter.o bytebuf.o bgwpool.o pglogical_output.o pglogical_proto.o pglogical_receiver.o pglogical_apply.o pglogical_hooks.o pglogical_config.o pglogical_relid_map.o ddd.o bkb.o spill.o referee.o state.o
55
MODULE_big = multimaster
66

77
PG_CPPFLAGS = -I$(libpq_srcdir)

contrib/mmts/arbiter.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474

7575

7676
#include "multimaster.h"
77+
#include "state.h"
7778

7879
#define MAX_ROUTES 16
7980
#define INIT_BUFFER_SIZE 1024
@@ -314,25 +315,22 @@ static void MtmCheckResponse(MtmArbiterMessage* resp)
314315
} else {
315316
BIT_CLEAR(Mtm->currentLockNodeMask, resp->node-1);
316317
}
317-
if (
318-
( BIT_CHECK(resp->disabledNodeMask, MtmNodeId-1) || Mtm->status == MTM_IN_MINORITY )
319-
&& !BIT_CHECK(Mtm->disabledNodeMask, resp->node-1)
320-
&& Mtm->status != MTM_RECOVERY
321-
&& Mtm->status != MTM_RECOVERED
322-
&& Mtm->nodes[MtmNodeId-1].lastStatusChangeTime + MSEC_TO_USEC(MtmNodeDisableDelay) < MtmGetSystemTime())
323-
{
324-
MTM_ELOG(WARNING, "Node %d thinks that I'm dead, while I'm %s (message %s)", resp->node, MtmNodeStatusMnem[Mtm->status], MtmMessageKindMnem[resp->code]);
325-
BIT_SET(Mtm->disabledNodeMask, MtmNodeId-1);
326-
Mtm->nConfigChanges += 1;
327-
MtmSwitchClusterMode(MTM_RECOVERY);
328-
} else if (BIT_CHECK(Mtm->disabledNodeMask, resp->node-1) && sockets[resp->node-1] < 0) {
329-
/* We receive heartbeat from disabled node.
318+
319+
if (BIT_CHECK(resp->disabledNodeMask, MtmNodeId-1))
320+
{
321+
MtmStateProcessEvent(MTM_REMOTE_DISABLE);
322+
}
323+
324+
if (BIT_CHECK(Mtm->disabledNodeMask, resp->node-1) &&
325+
sockets[resp->node-1] < 0)
326+
{
327+
/* We've received heartbeat from disabled node.
330328
* Looks like it is restarted.
331329
* Try to reconnect to it.
332330
*/
333331
MTM_ELOG(WARNING, "Receive heartbeat from disabled node %d", resp->node);
334332
BIT_SET(Mtm->reconnectMask, resp->node-1);
335-
}
333+
}
336334
}
337335

338336
static void MtmScheduleHeartbeat()
@@ -546,12 +544,7 @@ static void MtmOpenConnections()
546544
}
547545
}
548546
}
549-
if (Mtm->nLiveNodes < Mtm->nAllNodes/2+1) { /* no quorum */
550-
MTM_ELOG(WARNING, "Node is out of quorum: only %d nodes of %d are accessible", Mtm->nLiveNodes, Mtm->nAllNodes);
551-
MtmSwitchClusterMode(MTM_IN_MINORITY);
552-
} else if (Mtm->status == MTM_INITIALIZATION) {
553-
MtmSwitchClusterMode(MTM_CONNECTED);
554-
}
547+
MtmStateProcessEvent(MTM_ARBITER_RECEIVER_START);
555548
}
556549

557550

0 commit comments

Comments
 (0)