diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 27487ff304..52c747d041 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -4600,13 +4600,26 @@ void clusterSendPing(clusterLink *link, int type) { * Since we have non-voting replicas that lower the probability of an entry * to feature our node, we set the number of entries per packet as * 10% of the total nodes we have. */ - wanted = floor(dictSize(server.cluster->nodes) / 10); - if (wanted < 3) wanted = 3; - if (wanted > freshnodes) wanted = freshnodes; + int overall = server.cluster_ping_message_gossip_max_count; + if (!overall) { + overall = floor(dictSize(server.cluster->nodes) / 10); + if (overall < 3) overall = 3; + } - /* Include all the nodes in PFAIL state, so that failure reports are - * faster to propagate to go from PFAIL to FAIL state. */ + /* Prioritize pfail nodes over other nodes. + * Healthy nodes can communicate through direct ping/pong if required and failed node + * information would be broadcasted. */ int pfail_wanted = server.cluster->stats_pfail_nodes; + if (pfail_wanted >= overall) { + pfail_wanted = overall - 1; + wanted = 1; + } else { + wanted = overall - pfail_wanted; + } + + if (wanted > freshnodes) { + wanted = freshnodes; + } /* Compute the maximum estlen to allocate our buffer. We'll fix the estlen * later according to the number of gossip sections we really were able diff --git a/src/config.c b/src/config.c index d0158b2c4d..9a7f27d8bb 100644 --- a/src/config.c +++ b/src/config.c @@ -3350,6 +3350,8 @@ standardConfig static_configs[] = { createIntConfig("rdma-port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.rdma_ctx_config.port, 0, INTEGER_CONFIG, NULL, updateRdmaPort), createIntConfig("rdma-rx-size", NULL, IMMUTABLE_CONFIG, 64 * 1024, 16 * 1024 * 1024, server.rdma_ctx_config.rx_size, 1024 * 1024, INTEGER_CONFIG, NULL, NULL), createIntConfig("rdma-completion-vector", NULL, IMMUTABLE_CONFIG, -1, 1024, server.rdma_ctx_config.completion_vector, -1, INTEGER_CONFIG, NULL, NULL), + createIntConfig("cluster-ping-message-gossip-max-count", NULL, MODIFIABLE_CONFIG, 0, 2000, server.cluster_ping_message_gossip_max_count, 0, INTEGER_CONFIG, NULL, NULL), + /* Unsigned int configs */ createUIntConfig("maxclients", NULL, MODIFIABLE_CONFIG, 1, UINT_MAX, server.maxclients, 10000, INTEGER_CONFIG, NULL, updateMaxclients), @@ -3357,6 +3359,7 @@ standardConfig static_configs[] = { createUIntConfig("socket-mark-id", NULL, IMMUTABLE_CONFIG, 0, UINT_MAX, server.socket_mark_id, 0, INTEGER_CONFIG, NULL, NULL), createUIntConfig("max-new-connections-per-cycle", NULL, MODIFIABLE_CONFIG, 1, 1000, server.max_new_conns_per_cycle, 10, INTEGER_CONFIG, NULL, NULL), createUIntConfig("max-new-tls-connections-per-cycle", NULL, MODIFIABLE_CONFIG, 1, 1000, server.max_new_tls_conns_per_cycle, 1, INTEGER_CONFIG, NULL, NULL), + #ifdef LOG_REQ_RES createUIntConfig("client-default-resp", NULL, IMMUTABLE_CONFIG | HIDDEN_CONFIG, 2, 3, server.client_default_resp, 2, INTEGER_CONFIG, NULL, NULL), #endif diff --git a/src/server.h b/src/server.h index 24ca1ba82f..0c94416cb9 100644 --- a/src/server.h +++ b/src/server.h @@ -2182,6 +2182,7 @@ struct valkeyServer { int cluster_port; /* Set the cluster port for a node. */ mstime_t cluster_node_timeout; /* Cluster node timeout. */ mstime_t cluster_ping_interval; /* A debug configuration for setting how often cluster nodes send ping messages. */ + int cluster_ping_message_gossip_max_count; /* A configuration for setting how many peer node information to be gossiped in ping/pong messages. */ char *cluster_configfile; /* Cluster auto-generated config file name. */ struct clusterState *cluster; /* State of the cluster */ int cluster_migration_barrier; /* Cluster replicas migration barrier. */ diff --git a/valkey.conf b/valkey.conf index 1f6fe56d7e..d0ded453b7 100644 --- a/valkey.conf +++ b/valkey.conf @@ -2004,6 +2004,12 @@ aof-timestamp-enabled no # In order to setup your cluster make sure to read the documentation # available at https://valkey.io web site. +# Cluster nodes communicate with each other via PING/PONG message type. Each message carries a gossip section i.e. +# information about peer nodes. This configuration caps the maximum number of gossip information to carry in each message. +# +# Default value is set to 0 which implies the maximum count to be gossiped is set to 10% of all node count. +# cluster-ping-message-gossip-max-count 0 + ########################## CLUSTER DOCKER/NAT support ######################## # In certain deployments, cluster node's address discovery fails, because