Skip to content

Commit

Permalink
Update comments and log message in cluster_legacy.c (valkey-io#1561)
Browse files Browse the repository at this point in the history
Update comments and log message in `cluster_legacy.c`.

Follow-up from valkey-io#1441.

Signed-off-by: Pierre Turin <[email protected]>
Co-authored-by: Ping Xie <[email protected]>
Co-authored-by: Binbin <[email protected]>
Signed-off-by: proost <[email protected]>
  • Loading branch information
3 people authored and proost committed Jan 17, 2025
1 parent 6d6a9f7 commit e9a9894
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3282,8 +3282,8 @@ int clusterProcessPacket(clusterLink *link) {
/* Unable to retrieve the node's IP address from the connection. Without a
* valid IP, the node becomes unusable in the cluster. This failure might be
* due to the connection being closed. */
serverLog(LL_NOTICE, "Closing link even though we received a MEET packet on it, "
"because the connection has an error");
serverLog(LL_NOTICE, "Closing cluster link due to failure to retrieve IP from the connection, "
"possibly caused by a closed connection.");
freeClusterLink(link);
return 0;
}
Expand All @@ -3306,14 +3306,14 @@ int clusterProcessPacket(clusterLink *link) {
clusterAddNode(node);
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG);
} else {
/* A second MEET packet was received on an existing link during the handshake process.
* This happens when the other node detects no inbound link, and re-sends a MEET packet
* before this node can respond with a PING. This MEET is a no-op.
/* A second MEET packet was received on an existing link during the handshake
* process. This happens when the other node detects no inbound link, and
* re-sends a MEET packet before this node can respond with a PING.
* This MEET is a no-op.
*
* Note: Nodes in HANDSHAKE state are not fully "known" (random names), so the sender
* remains unidentified at this point. The MEET packet might be re-sent if the inbound
* connection is still unestablished by the next cron cycle.
*/
* Note: Nodes in HANDSHAKE state are not fully "known" (random names), so the
* sender remains unidentified at this point. The MEET packet might be re-sent
* if the inbound connection is still unestablished by the next cron cycle. */
debugServerAssert(link->inbound && nodeInHandshake(link->node));
}

Expand All @@ -3322,16 +3322,19 @@ int clusterProcessPacket(clusterLink *link) {
* of the message type. */
clusterProcessGossipSection(hdr, link);
} else if (sender->link && nodeExceedsHandshakeTimeout(sender, now)) {
/* The MEET packet is from a known node, after the handshake timeout, so the sender thinks that I do not
* know it.
* Free my outbound link to that node, triggering a reconnect and a PING over the new link.
* Once that node receives our PING, it should recognize the new connection as an inbound link from me.
* We should only free the outbound link if the node is known for more time than the handshake timeout,
* since during this time, the other side might still be trying to complete the handshake. */
/* The MEET packet is from a known node, after the handshake timeout, so the sender
* thinks that I do not know it.
* Free my outbound link to that node, triggering a reconnect and a PING over the
* new link.
* Once that node receives our PING, it should recognize the new connection as an
* inbound link from me. We should only free the outbound link if the node is known
* for more time than the handshake timeout, since during this time, the other side
* might still be trying to complete the handshake. */

/* We should always receive a MEET packet on an inbound link. */
serverAssert(link != sender->link);
serverLog(LL_NOTICE, "Freeing outbound link to node %.40s (%s) after receiving a MEET packet from this known node",
serverLog(LL_NOTICE, "Freeing outbound link to node %.40s (%s) after receiving a MEET packet "
"from this known node",
sender->name, sender->human_nodename);
freeClusterLink(sender->link);
}
Expand Down

0 comments on commit e9a9894

Please sign in to comment.