提交 3d455393 编写于 作者: A antirez

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.
上级 9531c848
......@@ -2875,12 +2875,16 @@ void clusterCommand(redisClient *c) {
/* CLUSTER FORGET <NODE ID> */
clusterNode *n = clusterLookupNode(c->argv[2]->ptr);
if (n == server.cluster->myself) {
addReplyErrorFormat(c,"I tried hard but I can't forget myself...");
return;
} else if (!n) {
if (!n) {
addReplyErrorFormat(c,"Unknown node %s", (char*)c->argv[2]->ptr);
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);
clusterDelNode(n);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册