mirror of
https://github.com/fluencelabs/redis
synced 2025-06-12 08:41:21 +00:00
Lua script selective replication fixes.
This commit is contained in:
34
src/server.c
34
src/server.c
@ -2224,29 +2224,34 @@ void call(client *c, int flags) {
|
||||
}
|
||||
|
||||
/* Propagate the command into the AOF and replication link */
|
||||
if (flags & CMD_CALL_PROPAGATE && (c->flags & CLIENT_PREVENT_PROP) == 0) {
|
||||
int flags = PROPAGATE_NONE;
|
||||
if (flags & CMD_CALL_PROPAGATE &&
|
||||
(c->flags & CLIENT_PREVENT_PROP) != CLIENT_PREVENT_PROP)
|
||||
{
|
||||
int propagate_flags = PROPAGATE_NONE;
|
||||
|
||||
/* Check if the command operated changes in the data set. If so
|
||||
* set for replication / AOF propagation. */
|
||||
if (dirty)
|
||||
flags |= (PROPAGATE_REPL | PROPAGATE_AOF);
|
||||
if (dirty) propagate_flags |= (PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
|
||||
/* If the command forced AOF / replication of the command, set
|
||||
* the flags regardless of the command effects on the data set. */
|
||||
if (c->flags & CLIENT_FORCE_REPL) flags |= PROPAGATE_REPL;
|
||||
if (c->flags & CLIENT_FORCE_AOF) flags |= PROPAGATE_AOF;
|
||||
|
||||
/* However calls to preventCommandPropagation() or its selective
|
||||
* variants preventCommandAOF() and preventCommandReplicaiton()
|
||||
* will clear the flags to avoid propagation. */
|
||||
if (c->flags & CLIENT_PREVENT_REPL_PROP) flags &= ~PROPAGATE_REPL;
|
||||
if (c->flags & CLIENT_PREVENT_AOF_PROP) flags &= ~PROPAGATE_AOF;
|
||||
/* However prevent AOF / replication propagation if the command
|
||||
* implementatino called preventCommandPropagation() or similar,
|
||||
* or if we don't have the call() flags to do so. */
|
||||
if (c->flags & CLIENT_PREVENT_REPL_PROP ||
|
||||
!(flags & CMD_CALL_PROPAGATE_REPL))
|
||||
propagate_flags &= ~PROPAGATE_REPL;
|
||||
if (c->flags & CLIENT_PREVENT_AOF_PROP ||
|
||||
!(flags & CMD_CALL_PROPAGATE_AOF))
|
||||
propagate_flags &= ~PROPAGATE_AOF;
|
||||
|
||||
/* Call propagate() only if at least one of AOF / replication
|
||||
* propagation is needed. */
|
||||
if (flags != PROPAGATE_NONE)
|
||||
propagate(c->cmd,c->db->id,c->argv,c->argc,flags);
|
||||
if (propagate_flags != PROPAGATE_NONE)
|
||||
propagate(c->cmd,c->db->id,c->argv,c->argc,propagate_flags);
|
||||
}
|
||||
|
||||
/* Restore the old replication flags, since call() can be executed
|
||||
@ -2265,7 +2270,12 @@ void call(client *c, int flags) {
|
||||
if (flags & CMD_CALL_PROPAGATE) {
|
||||
for (j = 0; j < server.also_propagate.numops; j++) {
|
||||
rop = &server.also_propagate.ops[j];
|
||||
propagate(rop->cmd,rop->dbid,rop->argv,rop->argc,rop->target);
|
||||
int target = rop->target;
|
||||
/* Whatever the command wish is, we honor the call() flags. */
|
||||
if (!(flags&CMD_CALL_PROPAGATE_AOF)) target &= ~PROPAGATE_AOF;
|
||||
if (!(flags&CMD_CALL_PROPAGATE_REPL)) target &= ~PROPAGATE_REPL;
|
||||
if (target)
|
||||
propagate(rop->cmd,rop->dbid,rop->argv,rop->argc,target);
|
||||
}
|
||||
}
|
||||
redisOpArrayFree(&server.also_propagate);
|
||||
|
Reference in New Issue
Block a user