From abf06e74ce12afd156124f67c389a31acd599acf Mon Sep 17 00:00:00 2001 From: Harkrishn Patro Date: Thu, 13 Nov 2025 14:23:44 -0800 Subject: [PATCH] Send duplicate multi meet packet only for node which support it Signed-off-by: Harkrishn Patro --- src/cluster_legacy.c | 13 +++++++++++-- src/cluster_legacy.h | 30 +++++++++++++++++------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 3767c430e5..32e0ced72b 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -1145,7 +1145,8 @@ void clusterUpdateMyselfFlags(void) { myself->flags |= nofailover; myself->flags |= CLUSTER_NODE_EXTENSIONS_SUPPORTED | CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED | - CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED; + CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED | + CLUSTER_NODE_MULTI_MEET_SUPPORTED; if (myself->flags != oldflags) { clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG | CLUSTER_TODO_UPDATE_STATE); } @@ -3673,6 +3674,13 @@ int clusterProcessPacket(clusterLink *link) { } else { sender->flags &= ~CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED; } + + /* Check if the node can handle multi meet packet. */ + if (flags & CLUSTER_NODE_MULTI_MEET_SUPPORTED) { + sender->flags |= CLUSTER_NODE_MULTI_MEET_SUPPORTED; + } else { + sender->flags &= ~CLUSTER_NODE_MULTI_MEET_SUPPORTED; + } } /* 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 } if (nodeInNormalState(node) && node->link != NULL && node->inbound_link == NULL && now - node->inbound_link_freed_time > getHandshakeTimeout() && - now - node->meet_sent > getHandshakeTimeout()) { + now - node->meet_sent > getHandshakeTimeout() && + nodeSupportsMultiMeet(node)) { /* Node has an outbound link, but no inbound link for more than the handshake timeout. * This probably means this node does not know us yet, whereas we know it. * So we send it a MEET packet to do a handshake with it and correct the inconsistent cluster view. diff --git a/src/cluster_legacy.h b/src/cluster_legacy.h index 56a3f10c43..109f330578 100644 --- a/src/cluster_legacy.h +++ b/src/cluster_legacy.h @@ -49,19 +49,22 @@ typedef struct clusterLink { #define linkSupportsExtension(link) ((link)->flags & CLUSTER_LINK_EXTENSIONS_SUPPORTED) /* Cluster node flags and macros. */ -#define CLUSTER_NODE_PRIMARY (1 << 0) /* The node is a primary */ -#define CLUSTER_NODE_REPLICA (1 << 1) /* The node is a replica */ -#define CLUSTER_NODE_PFAIL (1 << 2) /* Failure? Need acknowledge */ -#define CLUSTER_NODE_FAIL (1 << 3) /* The node is believed to be malfunctioning */ -#define CLUSTER_NODE_MYSELF (1 << 4) /* This node is myself */ -#define CLUSTER_NODE_HANDSHAKE (1 << 5) /* We have still to exchange the first ping */ -#define CLUSTER_NODE_NOADDR (1 << 6) /* We don't know the address of this node */ -#define CLUSTER_NODE_MEET (1 << 7) /* Send a MEET message to this node */ -#define CLUSTER_NODE_MIGRATE_TO (1 << 8) /* Primary eligible for replica migration. */ -#define CLUSTER_NODE_NOFAILOVER (1 << 9) /* Replica will not try to failover. */ -#define CLUSTER_NODE_EXTENSIONS_SUPPORTED (1 << 10) /* This node supports extensions. */ -#define CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED (1 << 11) /* This node supports light message header for publish type. */ -#define CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED (1 << 12) /* This node supports light message header for module type. */ +#define CLUSTER_NODE_PRIMARY (1 << 0) /* The node is a primary */ +#define CLUSTER_NODE_REPLICA (1 << 1) /* The node is a replica */ +#define CLUSTER_NODE_PFAIL (1 << 2) /* Failure? Need acknowledge */ +#define CLUSTER_NODE_FAIL (1 << 3) /* The node is believed to be malfunctioning */ +#define CLUSTER_NODE_MYSELF (1 << 4) /* This node is myself */ +#define CLUSTER_NODE_HANDSHAKE (1 << 5) /* We have still to exchange the first ping */ +#define CLUSTER_NODE_NOADDR (1 << 6) /* We don't know the address of this node */ +#define CLUSTER_NODE_MEET (1 << 7) /* Send a MEET message to this node */ +#define CLUSTER_NODE_MIGRATE_TO (1 << 8) /* Primary eligible for replica migration. */ +#define CLUSTER_NODE_NOFAILOVER (1 << 9) /* Replica will not try to failover. */ +#define CLUSTER_NODE_EXTENSIONS_SUPPORTED (1 << 10) /* This node supports extensions. */ +#define CLUSTER_NODE_LIGHT_HDR_PUBLISH_SUPPORTED (1 << 11) /* This node supports light message header for publish type. */ +#define CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED (1 << 12) /* This node supports light message header for module type. */ +#define CLUSTER_NODE_MULTI_MEET_SUPPORTED CLUSTER_NODE_LIGHT_HDR_MODULE_SUPPORTED /* This node handles multi meet packet. \ + Light hdr for module and multi meet were both introduced in 8.1, \ + so we could reduce the same flag value. */ #define CLUSTER_NODE_NULL_NAME \ "\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" \ "\000\000\000\000\000\000\000\000\000\000\000\000" @@ -75,6 +78,7 @@ typedef struct clusterLink { #define nodeFailed(n) ((n)->flags & CLUSTER_NODE_FAIL) #define nodeCantFailover(n) ((n)->flags & CLUSTER_NODE_NOFAILOVER) #define nodeSupportsExtensions(n) ((n)->flags & CLUSTER_NODE_EXTENSIONS_SUPPORTED) +#define nodeSupportsMultiMeet(n) ((n)->flags & CLUSTER_NODE_MULTI_MEET_SUPPORTED) #define nodeInNormalState(n) (!((n)->flags & (CLUSTER_NODE_HANDSHAKE | CLUSTER_NODE_MEET | CLUSTER_NODE_PFAIL | CLUSTER_NODE_FAIL))) /* Cluster messages header */