Skip to content

Commit a310215

Browse files
committed
move cluster state changing function to separate module
1 parent e8efbf4 commit a310215

File tree

9 files changed

+374
-241
lines changed

9 files changed

+374
-241
lines changed

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)

arbiter.c

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

7777

7878
#include "multimaster.h"
79+
#include "state.h"
7980

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

340338
static void MtmScheduleHeartbeat()
@@ -548,12 +546,7 @@ static void MtmOpenConnections()
548546
}
549547
}
550548
}
551-
if (Mtm->nLiveNodes < Mtm->nAllNodes/2+1) { /* no quorum */
552-
MTM_ELOG(WARNING, "Node is out of quorum: only %d nodes of %d are accessible", Mtm->nLiveNodes, Mtm->nAllNodes);
553-
MtmSwitchClusterMode(MTM_IN_MINORITY);
554-
} else if (Mtm->status == MTM_INITIALIZATION) {
555-
MtmSwitchClusterMode(MTM_CONNECTED);
556-
}
549+
MtmStateProcessEvent(MTM_ARBITER_RECEIVER_START);
557550
}
558551

559552

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy