Skip to content

Commit 86db609

Browse files
hpatrozuiderkwastenjoy-binbin
authored
Print node name on a best effort basis if light weight message is received before link stabilization (#2825)
fixes: #2803 --------- Signed-off-by: Harkrishn Patro <[email protected]> Signed-off-by: Harkrishn Patro <[email protected]> Co-authored-by: Viktor Söderqvist <[email protected]> Co-authored-by: Binbin <[email protected]>
1 parent b93cfcc commit 86db609

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/cluster_legacy.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,18 @@ static inline int defaultClientPort(void) {
167167
return server.tls_cluster ? server.tls_port : server.port;
168168
}
169169

170+
/* Return node name if the link has the node associated to it
171+
* or else return "<unknown>". */
172+
static inline char *clusterLinkGetNodeName(clusterLink *link) {
173+
return link->node ? link->node->name : "<unknown>";
174+
}
175+
176+
/* Return human assigned node name if the link has the node associated to it
177+
* or else return "<unknown>". */
178+
static inline char *clusterLinkGetHumanNodeName(clusterLink *link) {
179+
return link->node ? link->node->human_nodename : "<unknown>";
180+
}
181+
170182
#define isSlotUnclaimed(slot) \
171183
(server.cluster->slots[slot] == NULL || bitmapTestBit(server.cluster->owner_not_claiming_slot, slot))
172184

@@ -1653,9 +1665,9 @@ clusterLink *createClusterLink(clusterNode *node) {
16531665
void freeClusterLink(clusterLink *link) {
16541666
serverAssert(link != NULL);
16551667
serverLog(LL_DEBUG, "Freeing cluster link for node: %.40s:%s (%s)",
1656-
link->node ? link->node->name : "<unknown>",
1668+
clusterLinkGetNodeName(link),
16571669
link->inbound ? "inbound" : "outbound",
1658-
link->node ? link->node->human_nodename : "<unknown>");
1670+
clusterLinkGetHumanNodeName(link));
16591671

16601672
if (link->conn) {
16611673
connClose(link->conn);
@@ -3628,8 +3640,9 @@ int clusterProcessPacket(clusterLink *link) {
36283640
if (!link->node || nodeInHandshake(link->node)) {
36293641
serverLog(
36303642
LL_NOTICE,
3631-
"Closing link for node %.40s that sent a lightweight message of type %s as its first message on the link",
3632-
hdr->sender,
3643+
"Closing link for node %.40s (%s) that sent a lightweight message of type %s as its first message on the link",
3644+
clusterLinkGetNodeName(link),
3645+
clusterLinkGetHumanNodeName(link),
36333646
clusterGetMessageTypeString(type));
36343647
freeClusterLink(link);
36353648
return 0;
@@ -3823,7 +3836,7 @@ int clusterProcessPacket(clusterLink *link) {
38233836
/* PING, PONG, MEET: process config information. */
38243837
if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_PONG || type == CLUSTERMSG_TYPE_MEET) {
38253838
serverLog(LL_DEBUG, "%s packet received: %.40s", clusterGetMessageTypeString(type),
3826-
link->node ? link->node->name : "NULL");
3839+
clusterLinkGetNodeName(link));
38273840

38283841
if (sender && nodeInMeetState(sender)) {
38293842
/* Once we get a response for MEET from the sender, we can stop sending more MEET. */
@@ -4372,9 +4385,10 @@ void clusterReadHandler(connection *conn) {
43724385

43734386
if (nread <= 0) {
43744387
/* I/O error... */
4375-
serverLog(LL_DEBUG, "I/O error reading from node link (%.40s:%s): %s",
4376-
link->node ? link->node->name : "<unknown>",
4388+
serverLog(LL_DEBUG, "I/O error reading from node link (%.40s:%s) (%s): %s",
4389+
clusterLinkGetNodeName(link),
43774390
link->inbound ? "inbound" : "outbound",
4391+
clusterLinkGetHumanNodeName(link),
43784392
(nread == 0) ? "connection closed" : connGetLastError(conn));
43794393
handleLinkIOError(link);
43804394
return;
@@ -4557,8 +4571,8 @@ void clusterSetGossipEntry(clusterMsg *hdr, int i, clusterNode *n) {
45574571
void clusterSendPing(clusterLink *link, int type) {
45584572
serverLog(LL_DEBUG, "Sending %s packet to node %.40s (%s) on %s link",
45594573
clusterGetMessageTypeString(type),
4560-
link->node ? link->node->name : "<unknown>",
4561-
link->node ? link->node->human_nodename : "<unknown>",
4574+
clusterLinkGetNodeName(link),
4575+
clusterLinkGetHumanNodeName(link),
45624576
link->inbound ? "inbound" : "outbound");
45634577

45644578
static unsigned long long cluster_pings_sent = 0;
@@ -5780,9 +5794,9 @@ static void freeClusterLinkOnBufferLimitReached(clusterLink *link) {
57805794
unsigned long long mem_link = link->send_msg_queue_mem;
57815795
if (mem_link > server.cluster_link_msg_queue_limit_bytes) {
57825796
serverLog(LL_WARNING,
5783-
"Freeing cluster link(%s node %.40s, used memory: %llu) due to "
5797+
"Freeing cluster link(%s node %.40s (%s), used memory: %llu) due to "
57845798
"exceeding send buffer memory limit.",
5785-
link->inbound ? "from" : "to", link->node ? link->node->name : "", mem_link);
5799+
link->inbound ? "from" : "to", clusterLinkGetNodeName(link), clusterLinkGetHumanNodeName(link), mem_link);
57865800
freeClusterLink(link);
57875801
server.cluster->stat_cluster_links_buffer_limit_exceeded++;
57885802
}

0 commit comments

Comments
 (0)