Skip to content

Commit

Permalink
Cluster: fix Lua scripts replication to slave nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Mar 22, 2015
1 parent 1641f41 commit c271791
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,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;
Expand Down
5 changes: 3 additions & 2 deletions src/scripting.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c271791

Please sign in to comment.