Commit 3d455393 authored by antirez's avatar antirez
Browse files

Cluster: don't let a node forget its own master.

redis-trib should make sure to reconfigure slaves of a node to remove
from the cluster to replicate with other nodes before sending CLUSTER
FORGET.
parent 9531c848
...@@ -2875,12 +2875,16 @@ void clusterCommand(redisClient *c) { ...@@ -2875,12 +2875,16 @@ void clusterCommand(redisClient *c) {
/* CLUSTER FORGET <NODE ID> */ /* CLUSTER FORGET <NODE ID> */
clusterNode *n = clusterLookupNode(c->argv[2]->ptr); clusterNode *n = clusterLookupNode(c->argv[2]->ptr);
if (n == server.cluster->myself) { if (!n) {
addReplyErrorFormat(c,"I tried hard but I can't forget myself...");
return;
} else if (!n) {
addReplyErrorFormat(c,"Unknown node %s", (char*)c->argv[2]->ptr); addReplyErrorFormat(c,"Unknown node %s", (char*)c->argv[2]->ptr);
return; return;
} else if (n == server.cluster->myself) {
addReplyError(c,"I tried hard but I can't forget myself...");
return;
} else if (server.cluster->myself->flags & REDIS_NODE_SLAVE &&
server.cluster->myself->slaveof == n) {
addReplyError(c,"Can't forget my master!");
return;
} }
clusterBlacklistAddNode(n); clusterBlacklistAddNode(n);
clusterDelNode(n); clusterDelNode(n);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment