mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 15:21:03 +00:00
Propagate read-only scripts as SCRIPT LOAD.
See issue #5250 and the new comments added to the code in this commit for details.
This commit is contained in:
parent
51b627d916
commit
092e4de613
@ -1250,6 +1250,7 @@ void evalGenericCommand(client *c, int evalsha) {
|
|||||||
lua_State *lua = server.lua;
|
lua_State *lua = server.lua;
|
||||||
char funcname[43];
|
char funcname[43];
|
||||||
long long numkeys;
|
long long numkeys;
|
||||||
|
long long initial_server_dirty = server.dirty;
|
||||||
int delhook = 0, err;
|
int delhook = 0, err;
|
||||||
|
|
||||||
/* When we replicate whole scripts, we want the same PRNG sequence at
|
/* When we replicate whole scripts, we want the same PRNG sequence at
|
||||||
@ -1432,9 +1433,21 @@ void evalGenericCommand(client *c, int evalsha) {
|
|||||||
|
|
||||||
replicationScriptCacheAdd(c->argv[1]->ptr);
|
replicationScriptCacheAdd(c->argv[1]->ptr);
|
||||||
serverAssertWithInfo(c,NULL,script != NULL);
|
serverAssertWithInfo(c,NULL,script != NULL);
|
||||||
rewriteClientCommandArgument(c,0,
|
|
||||||
resetRefCount(createStringObject("EVAL",4)));
|
/* If the script did not produce any changes in the dataset we want
|
||||||
rewriteClientCommandArgument(c,1,script);
|
* just to replicate it as SCRIPT LOAD, otherwise we risk running
|
||||||
|
* an aborted script on slaves (that may then produce results there)
|
||||||
|
* or just running a CPU costly read-only script on the slaves. */
|
||||||
|
if (server.dirty == initial_server_dirty) {
|
||||||
|
rewriteClientCommandVector(c,3,
|
||||||
|
resetRefCount(createStringObject("SCRIPT",6)),
|
||||||
|
resetRefCount(createStringObject("LOAD",4)),
|
||||||
|
script);
|
||||||
|
} else {
|
||||||
|
rewriteClientCommandArgument(c,0,
|
||||||
|
resetRefCount(createStringObject("EVAL",4)));
|
||||||
|
rewriteClientCommandArgument(c,1,script);
|
||||||
|
}
|
||||||
forceCommandPropagation(c,PROPAGATE_REPL|PROPAGATE_AOF);
|
forceCommandPropagation(c,PROPAGATE_REPL|PROPAGATE_AOF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user