From 8695d9602471f318ef8b9db7e0400642b4309873 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 30 Oct 2015 10:13:04 +0100 Subject: [PATCH] Scripting: ability to turn on Lua commands style replication globally. Currently this feature is only accessible via DEBUG for testing, since otherwise depending on the instance configuration a given script works or is broken, which is against the Redis philosophy. --- src/debug.c | 5 +++++ src/scripting.c | 2 +- src/server.c | 1 + src/server.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/debug.c b/src/debug.c index a96444627..db3420280 100644 --- a/src/debug.c +++ b/src/debug.c @@ -425,6 +425,11 @@ void debugCommand(client *c) { { server.active_expire_enabled = atoi(c->argv[2]->ptr); addReply(c,shared.ok); + } else if (!strcasecmp(c->argv[1]->ptr,"lua-always-replicate-commands") && + c->argc == 3) + { + server.lua_always_replicate_commands = atoi(c->argv[2]->ptr); + addReply(c,shared.ok); } else if (!strcasecmp(c->argv[1]->ptr,"error") && c->argc == 3) { sds errstr = sdsnewlen("-",1); diff --git a/src/scripting.c b/src/scripting.c index 4d50f9fb0..af7dd49f7 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -1038,7 +1038,7 @@ void evalGenericCommand(client *c, int evalsha) { * is called after a random command was used. */ server.lua_random_dirty = 0; server.lua_write_dirty = 0; - server.lua_replicate_commands = 0; + server.lua_replicate_commands = server.lua_always_replicate_commands; server.lua_multi_emitted = 0; server.lua_repl = PROPAGATE_AOF|PROPAGATE_REPL; diff --git a/src/server.c b/src/server.c index f7f4a0bf2..a2eb26eb4 100644 --- a/src/server.c +++ b/src/server.c @@ -1499,6 +1499,7 @@ void initServerConfig(void) { server.lua_time_limit = LUA_SCRIPT_TIME_LIMIT; server.lua_client = NULL; server.lua_timedout = 0; + server.lua_always_replicate_commands = 0; /* Only DEBUG can change it. */ server.migrate_cached_sockets = dictCreate(&migrateCacheDictType,NULL); server.next_client_id = 1; /* Client IDs, start from 1 .*/ server.loading_process_events_interval_bytes = (1024*1024*2); diff --git a/src/server.h b/src/server.h index b2013c979..3c8571ed2 100644 --- a/src/server.h +++ b/src/server.h @@ -953,6 +953,7 @@ struct redisServer { int lua_timedout; /* True if we reached the time limit for script execution. */ int lua_kill; /* Kill the script if true. */ + int lua_always_replicate_commands; /* Default replication type. */ /* Latency monitor */ long long latency_monitor_threshold; dict *latency_events;