Fixed semantics of CLUSTER SETSLOT, SELECT now only denied in cluster mode if selected DB is not 0 so that MIGRATE still works well.

This commit is contained in:
antirez 2011-05-05 18:10:02 +02:00
parent 46834808fe
commit a7b058dae6
2 changed files with 10 additions and 5 deletions

View File

@ -1219,11 +1219,11 @@ void clusterCommand(redisClient *c) {
return;
}
slot = (unsigned int) aux;
if (server.cluster.slots[slot] != server.cluster.myself) {
addReplyErrorFormat(c,"I'm not the owner of hash slot %u",slot);
return;
}
if (!strcasecmp(c->argv[3]->ptr,"migrating") && c->argc == 5) {
if (server.cluster.slots[slot] != server.cluster.myself) {
addReplyErrorFormat(c,"I'm not the owner of hash slot %u",slot);
return;
}
if ((n = clusterLookupNode(c->argv[4]->ptr)) == NULL) {
addReplyErrorFormat(c,"I don't know about node %s",
(char*)c->argv[4]->ptr);
@ -1231,6 +1231,11 @@ void clusterCommand(redisClient *c) {
}
server.cluster.migrating_slots_to[slot] = n;
} else if (!strcasecmp(c->argv[3]->ptr,"importing") && c->argc == 5) {
if (server.cluster.slots[slot] == server.cluster.myself) {
addReplyErrorFormat(c,
"I'm already the owner of hash slot %u",slot);
return;
}
if ((n = clusterLookupNode(c->argv[4]->ptr)) == NULL) {
addReplyErrorFormat(c,"I don't know about node %s",
(char*)c->argv[3]->ptr);

View File

@ -317,7 +317,7 @@ void existsCommand(redisClient *c) {
void selectCommand(redisClient *c) {
int id = atoi(c->argv[1]->ptr);
if (server.cluster_enabled) {
if (server.cluster_enabled && id != 0) {
addReplyError(c,"SELECT is not allowed in cluster mode");
return;
}