diff --git a/src/scripting.c b/src/scripting.c index 4b5b0002..43f8d09a 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -512,10 +512,13 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) { * could enlarge the memory usage are not allowed, but only if this is the * first write in the context of this script, otherwise we can't stop * in the middle. */ - if (server.maxmemory && server.lua_write_dirty == 0 && + if (server.maxmemory && /* Maxmemory is actually enabled. */ + !server.loading && /* Don't care about mem if loading. */ + !server.masterhost && /* Slave must execute the script. */ + server.lua_write_dirty == 0 && /* Script had no side effects so far. */ (cmd->flags & CMD_DENYOOM)) { - if (freeMemoryIfNeeded() == C_ERR) { + if (getMaxmemoryState(NULL,NULL,NULL,NULL) != C_OK) { luaPushError(lua, shared.oomerr->ptr); goto cleanup; }