From ed0cfc31f3e84a94fc5810409ce552c3f34ceebb Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 15 Jan 2014 16:50:45 +0100 Subject: [PATCH] Cluster: use the node blacklist in CLUSTER FORGET. CLUSTER FORGET is not useful if we can't remove a node from all the nodes of our cluster because of the Gossip protocol that keeps adding a given node to nodes where we already tried to remove it. So now CLUSTER FORGET implements a nodes blacklist that is set and checked by the Gossip section processing function. This way before a node is re-added at least 60 seconds must elapse since the FORGET execution. This means that redis-trib has some time to remove a node from a whole cluster. It is possible that in the future it will be uesful to raise the 60 sec figure to something bigger. --- src/cluster.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cluster.c b/src/cluster.c index d6c7baa1e..e5081936f 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -967,8 +967,12 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) { * Note that we require that the sender of this gossip message * is a well known node in our cluster, otherwise we risk * joining another cluster. */ - if (sender && !(flags & REDIS_NODE_NOADDR)) + if (sender && + !(flags & REDIS_NODE_NOADDR) && + !clusterBlacklistExists(g->nodename)) + { clusterStartHandshake(g->ip,ntohs(g->port)); + } } /* Next node */ @@ -2875,6 +2879,7 @@ void clusterCommand(redisClient *c) { addReplyErrorFormat(c,"Unknown node %s", (char*)c->argv[2]->ptr); return; } + clusterBlacklistAddNode(n); clusterDelNode(n); clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE|CLUSTER_TODO_SAVE_CONFIG); addReply(c,shared.ok);