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.
This commit is contained in:
antirez 2014-01-17 18:22:35 +01:00
parent 1caae15fdd
commit aa79af76fc

View File

@ -2912,10 +2912,12 @@ void clusterCommand(redisClient *c) {
return; return;
} }
/* We should have no assigned slots to accept to replicate some /* If the instance is currently a master, it should have no assigned
* other node. */ * slots nor keys to accept to replicate some other node.
if (server.cluster->myself->numslots != 0 || * Slaves can switch to another master without issues. */
dictSize(server.db[0].dict) != 0) 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."); addReplyError(c,"To set a master the node must be empty and without assigned slots.");
return; return;