mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 16:40:50 +00:00
Cluster: free HANDSHAKE nodes after node_timeout.
Handshake nodes should turn into normal nodes or be freed in a reasonable amount of time, otherwise they'll keep accumulating if the address they are associated with is not reachable for some reason.
This commit is contained in:
parent
2debce325b
commit
72587e6cc5
@ -359,6 +359,7 @@ clusterNode *createClusterNode(char *nodename, int flags) {
|
||||
memcpy(node->name, nodename, REDIS_CLUSTER_NAMELEN);
|
||||
else
|
||||
getRandomHexChars(node->name, REDIS_CLUSTER_NAMELEN);
|
||||
node->ctime = time(NULL);
|
||||
node->flags = flags;
|
||||
memset(node->slots,0,sizeof(node->slots));
|
||||
node->numslots = 0;
|
||||
@ -1588,6 +1589,16 @@ void clusterCron(void) {
|
||||
clusterNode *node = dictGetVal(de);
|
||||
|
||||
if (node->flags & (REDIS_NODE_MYSELF|REDIS_NODE_NOADDR)) continue;
|
||||
|
||||
/* A Node in HANDSHAKE state has a limited lifespan equal to the
|
||||
* configured node timeout. */
|
||||
if (node->flags & REDIS_NODE_HANDSHAKE &&
|
||||
server.unixtime - node->ctime > server.cluster_node_timeout)
|
||||
{
|
||||
freeClusterNode(node);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node->link == NULL) {
|
||||
int fd;
|
||||
time_t old_ping_sent;
|
||||
|
@ -614,6 +614,7 @@ struct clusterNodeFailReport {
|
||||
} typedef clusterNodeFailReport;
|
||||
|
||||
struct clusterNode {
|
||||
time_t ctime; /* Node object creation time. */
|
||||
char name[REDIS_CLUSTER_NAMELEN]; /* Node name, hex string, sha1-size */
|
||||
int flags; /* REDIS_NODE_... */
|
||||
unsigned char slots[REDIS_CLUSTER_SLOTS/8]; /* slots handled by this node */
|
||||
|
Loading…
x
Reference in New Issue
Block a user