From d3b4662347a1099d90339328ef6df7bc939cf42a Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Tue, 5 Mar 2013 13:02:44 +0100
Subject: [PATCH] Cluster: don't check keys hash slots when the source is our
 master.

Usually we redirect clients to the right hash slot, however we don't
want to do that with our master, we want just to mirror it.
---
 src/redis.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/redis.c b/src/redis.c
index c4cebf6d..f73cd79c 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -1663,9 +1663,14 @@ int processCommand(redisClient *c) {
         return REDIS_OK;
     }
 
-    /* If cluster is enabled, redirect here */
+    /* If cluster is enabled perform the cluster redirection here.
+     * However we don't perform the redirection if:
+     * 1) The sender of this command is our master.
+     * 2) The command has no key arguments. */
     if (server.cluster_enabled &&
-                !(c->cmd->getkeys_proc == NULL && c->cmd->firstkey == 0)) {
+        !(c->flags & REDIS_MASTER) &&
+        !(c->cmd->getkeys_proc == NULL && c->cmd->firstkey == 0))
+    {
         int hashslot;
 
         if (server.cluster->state != REDIS_CLUSTER_OK) {