Commit ac3850ca authored by antirez's avatar antirez
Browse files

Cluster: allow CLUSTER REPLICATE to switch master.

The code was doing checks for slaves that should be done only when the
instance is currently a master. Switching a slave from a master to
another one should just work.
parent abd6308d
......@@ -2912,10 +2912,12 @@ void clusterCommand(redisClient *c) {
return;
}
/* We should have no assigned slots to accept to replicate some
* other node. */
if (server.cluster->myself->numslots != 0 ||
dictSize(server.db[0].dict) != 0)
/* If the instance is currently a master, it should have no assigned
* slots nor keys to accept to replicate some other node.
* Slaves can switch to another master without issues. */
if (server.cluster->myself->flags & REDIS_NODE_MASTER &&
(server.cluster->myself->numslots != 0 ||
dictSize(server.db[0].dict) != 0))
{
addReplyError(c,"To set a master the node must be empty and without assigned slots.");
return;
......
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