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.
This commit is contained in:
antirez 2015-10-30 10:13:04 +01:00
parent eda06b51fb
commit ff6d296000
4 changed files with 8 additions and 1 deletions

View File

@ -423,6 +423,11 @@ void debugCommand(client *c) {
{ {
server.active_expire_enabled = atoi(c->argv[2]->ptr); server.active_expire_enabled = atoi(c->argv[2]->ptr);
addReply(c,shared.ok); 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) { } else if (!strcasecmp(c->argv[1]->ptr,"error") && c->argc == 3) {
sds errstr = sdsnewlen("-",1); sds errstr = sdsnewlen("-",1);

View File

@ -1038,7 +1038,7 @@ void evalGenericCommand(client *c, int evalsha) {
* is called after a random command was used. */ * is called after a random command was used. */
server.lua_random_dirty = 0; server.lua_random_dirty = 0;
server.lua_write_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_multi_emitted = 0;
server.lua_repl = PROPAGATE_AOF|PROPAGATE_REPL; server.lua_repl = PROPAGATE_AOF|PROPAGATE_REPL;

View File

@ -1512,6 +1512,7 @@ void initServerConfig(void) {
server.lua_time_limit = LUA_SCRIPT_TIME_LIMIT; server.lua_time_limit = LUA_SCRIPT_TIME_LIMIT;
server.lua_client = NULL; server.lua_client = NULL;
server.lua_timedout = 0; server.lua_timedout = 0;
server.lua_always_replicate_commands = 0; /* Only DEBUG can change it. */
server.migrate_cached_sockets = dictCreate(&migrateCacheDictType,NULL); server.migrate_cached_sockets = dictCreate(&migrateCacheDictType,NULL);
server.next_client_id = 1; /* Client IDs, start from 1 .*/ server.next_client_id = 1; /* Client IDs, start from 1 .*/
server.loading_process_events_interval_bytes = (1024*1024*2); server.loading_process_events_interval_bytes = (1024*1024*2);

View File

@ -960,6 +960,7 @@ struct redisServer {
int lua_timedout; /* True if we reached the time limit for script int lua_timedout; /* True if we reached the time limit for script
execution. */ execution. */
int lua_kill; /* Kill the script if true. */ int lua_kill; /* Kill the script if true. */
int lua_always_replicate_commands; /* Default replication type. */
/* Lazy free */ /* Lazy free */
int lazyfree_lazy_eviction; int lazyfree_lazy_eviction;
int lazyfree_lazy_expire; int lazyfree_lazy_expire;