summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-03-22 22:23:41 +0100
committerantirez <antirez@gmail.com>2015-03-22 22:24:08 +0100
commit2f4240b9d9e36b83fcd6bf2525484effabe69298 (patch)
tree03c018391e5ca1b935d4dbd8a1b58f39bb4b5490
parent94030fa4d7962a8e241ad27cadbc71a0f1b61d1b (diff)
downloadredis-2f4240b9d9e36b83fcd6bf2525484effabe69298.tar.gz
Cluster: fix Lua scripts replication to slave nodes.
-rw-r--r--src/redis.c2
-rw-r--r--src/scripting.c5
2 files changed, 5 insertions, 2 deletions
diff --git a/src/redis.c b/src/redis.c
index 3f887f3e7..81fa7be2f 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -2199,6 +2199,8 @@ int processCommand(redisClient *c) {
* 2) The command has no key arguments. */
if (server.cluster_enabled &&
!(c->flags & REDIS_MASTER) &&
+ !(c->flags & REDIS_LUA_CLIENT &&
+ server.lua_caller->flags & REDIS_MASTER) &&
!(c->cmd->getkeys_proc == NULL && c->cmd->firstkey == 0))
{
int hashslot;
diff --git a/src/scripting.c b/src/scripting.c
index c5dd4e718..4f807f4e2 100644
--- a/src/scripting.c
+++ b/src/scripting.c
@@ -357,8 +357,9 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
if (cmd->flags & REDIS_CMD_WRITE) server.lua_write_dirty = 1;
/* If this is a Redis Cluster node, we need to make sure Lua is not
- * trying to access non-local keys. */
- if (server.cluster_enabled) {
+ * trying to access non-local keys, with the exception of commands
+ * received from our master. */
+ if (server.cluster_enabled && !(server.lua_caller->flags & REDIS_MASTER)) {
/* Duplicate relevant flags in the lua client. */
c->flags &= ~(REDIS_READONLY|REDIS_ASKING);
c->flags |= server.lua_caller->flags & (REDIS_READONLY|REDIS_ASKING);