Skip to content

Commit abf06e7

Browse files
committed
Send duplicate multi meet packet only for node which support it
Signed-off-by: Harkrishn Patro <[email protected]>
1 parent 01a7657 commit abf06e7

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

src/cluster_legacy.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,8 @@ void clusterUpdateMyselfFlags(void) {
11451145
myself->flags |= nofailover;
11461146
myself->flags |= CLUSTER_NODE_EXTENSIONS_SUPPORTED |
11471147
CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED |
1148-
CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED;
1148+
CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED |
1149+
CLUSTER_NODE_MULTI_MEET_SUPPORTED;
11491150
if (myself->flags != oldflags) {
11501151
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG | CLUSTER_TODO_UPDATE_STATE);
11511152
}
@@ -3673,6 +3674,13 @@ int clusterProcessPacket(clusterLink *link) {
36733674
} else {
36743675
sender->flags &= ~CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED;
36753676
}
3677+
3678+
/* Check if the node can handle multi meet packet. */
3679+
if (flags & CLUSTER_NODE_MULTI_MEET_SUPPORTED) {
3680+
sender->flags |= CLUSTER_NODE_MULTI_MEET_SUPPORTED;
3681+
} else {
3682+
sender->flags &= ~CLUSTER_NODE_MULTI_MEET_SUPPORTED;
3683+
}
36763684
}
36773685

36783686
/* Update the last time we saw any data from this node. We
@@ -5725,7 +5733,8 @@ static int clusterNodeCronHandleReconnect(clusterNode *node, mstime_t now, long
57255733
}
57265734
if (nodeInNormalState(node) && node->link != NULL && node->inbound_link == NULL &&
57275735
now - node->inbound_link_freed_time > getHandshakeTimeout() &&
5728-
now - node->meet_sent > getHandshakeTimeout()) {
5736+
now - node->meet_sent > getHandshakeTimeout() &&
5737+
nodeSupportsMultiMeet(node)) {
57295738
/* Node has an outbound link, but no inbound link for more than the handshake timeout.
57305739
* This probably means this node does not know us yet, whereas we know it.
57315740
* So we send it a MEET packet to do a handshake with it and correct the inconsistent cluster view.

src/cluster_legacy.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,22 @@ typedef struct clusterLink {
4949
#define linkSupportsExtension(link) ((link)->flags & CLUSTER_LINK_EXTENSIONS_SUPPORTED)
5050

5151
/* Cluster node flags and macros. */
52-
#define CLUSTER_NODE_PRIMARY (1 << 0) /* The node is a primary */
53-
#define CLUSTER_NODE_REPLICA (1 << 1) /* The node is a replica */
54-
#define CLUSTER_NODE_PFAIL (1 << 2) /* Failure? Need acknowledge */
55-
#define CLUSTER_NODE_FAIL (1 << 3) /* The node is believed to be malfunctioning */
56-
#define CLUSTER_NODE_MYSELF (1 << 4) /* This node is myself */
57-
#define CLUSTER_NODE_HANDSHAKE (1 << 5) /* We have still to exchange the first ping */
58-
#define CLUSTER_NODE_NOADDR (1 << 6) /* We don't know the address of this node */
59-
#define CLUSTER_NODE_MEET (1 << 7) /* Send a MEET message to this node */
60-
#define CLUSTER_NODE_MIGRATE_TO (1 << 8) /* Primary eligible for replica migration. */
61-
#define CLUSTER_NODE_NOFAILOVER (1 << 9) /* Replica will not try to failover. */
62-
#define CLUSTER_NODE_EXTENSIONS_SUPPORTED (1 << 10) /* This node supports extensions. */
63-
#define CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED (1 << 11) /* This node supports light message header for publish type. */
64-
#define CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED (1 << 12) /* This node supports light message header for module type. */
52+
#define CLUSTER_NODE_PRIMARY (1 << 0) /* The node is a primary */
53+
#define CLUSTER_NODE_REPLICA (1 << 1) /* The node is a replica */
54+
#define CLUSTER_NODE_PFAIL (1 << 2) /* Failure? Need acknowledge */
55+
#define CLUSTER_NODE_FAIL (1 << 3) /* The node is believed to be malfunctioning */
56+
#define CLUSTER_NODE_MYSELF (1 << 4) /* This node is myself */
57+
#define CLUSTER_NODE_HANDSHAKE (1 << 5) /* We have still to exchange the first ping */
58+
#define CLUSTER_NODE_NOADDR (1 << 6) /* We don't know the address of this node */
59+
#define CLUSTER_NODE_MEET (1 << 7) /* Send a MEET message to this node */
60+
#define CLUSTER_NODE_MIGRATE_TO (1 << 8) /* Primary eligible for replica migration. */
61+
#define CLUSTER_NODE_NOFAILOVER (1 << 9) /* Replica will not try to failover. */
62+
#define CLUSTER_NODE_EXTENSIONS_SUPPORTED (1 << 10) /* This node supports extensions. */
63+
#define CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED (1 << 11) /* This node supports light message header for publish type. */
64+
#define CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED (1 << 12) /* This node supports light message header for module type. */
65+
#define CLUSTER_NODE_MULTI_MEET_SUPPORTED CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED /* This node handles multi meet packet. \
66+
Light hdr for module and multi meet were both introduced in 8.1, \
67+
so we could reduce the same flag value. */
6568
#define CLUSTER_NODE_NULL_NAME \
6669
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" \
6770
"\000\000\000\000\000\000\000\000\000\000\000\000"
@@ -75,6 +78,7 @@ typedef struct clusterLink {
7578
#define nodeFailed(n) ((n)->flags & CLUSTER_NODE_FAIL)
7679
#define nodeCantFailover(n) ((n)->flags & CLUSTER_NODE_NOFAILOVER)
7780
#define nodeSupportsExtensions(n) ((n)->flags & CLUSTER_NODE_EXTENSIONS_SUPPORTED)
81+
#define nodeSupportsMultiMeet(n) ((n)->flags & CLUSTER_NODE_MULTI_MEET_SUPPORTED)
7882
#define nodeInNormalState(n) (!((n)->flags & (CLUSTER_NODE_HANDSHAKE | CLUSTER_NODE_MEET | CLUSTER_NODE_PFAIL | CLUSTER_NODE_FAIL)))
7983

8084
/* Cluster messages header */

0 commit comments

Comments
 (0)