mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Modules: fix for scripting replication of modules commands.
See issue #4466 / #4467.
This commit is contained in:
parent
ada206559d
commit
de914ede93
11
src/module.c
11
src/module.c
@ -442,9 +442,7 @@ void moduleFreeContext(RedisModuleCtx *ctx) {
|
|||||||
void moduleHandlePropagationAfterCommandCallback(RedisModuleCtx *ctx) {
|
void moduleHandlePropagationAfterCommandCallback(RedisModuleCtx *ctx) {
|
||||||
client *c = ctx->client;
|
client *c = ctx->client;
|
||||||
|
|
||||||
/* We don't want any automatic propagation here since in modules we handle
|
if (c->flags & CLIENT_LUA) return;
|
||||||
* replication / AOF propagation in explicit ways. */
|
|
||||||
preventCommandPropagation(c);
|
|
||||||
|
|
||||||
/* Handle the replication of the final EXEC, since whatever a command
|
/* Handle the replication of the final EXEC, since whatever a command
|
||||||
* emits is always wrappered around MULTI/EXEC. */
|
* emits is always wrappered around MULTI/EXEC. */
|
||||||
@ -1164,8 +1162,9 @@ int RM_ReplyWithDouble(RedisModuleCtx *ctx, double d) {
|
|||||||
* in the context of a command execution. EXEC will be handled by the
|
* in the context of a command execution. EXEC will be handled by the
|
||||||
* RedisModuleCommandDispatcher() function. */
|
* RedisModuleCommandDispatcher() function. */
|
||||||
void moduleReplicateMultiIfNeeded(RedisModuleCtx *ctx) {
|
void moduleReplicateMultiIfNeeded(RedisModuleCtx *ctx) {
|
||||||
/* Skip this if client explicitly wrap the command with MULTI */
|
/* Skip this if client explicitly wrap the command with MULTI, or if
|
||||||
if (ctx->client->flags & CLIENT_MULTI) return;
|
* the module command was called by a script. */
|
||||||
|
if (ctx->client->flags & (CLIENT_MULTI|CLIENT_LUA)) return;
|
||||||
/* If we already emitted MULTI return ASAP. */
|
/* If we already emitted MULTI return ASAP. */
|
||||||
if (ctx->flags & REDISMODULE_CTX_MULTI_EMITTED) return;
|
if (ctx->flags & REDISMODULE_CTX_MULTI_EMITTED) return;
|
||||||
/* If this is a thread safe context, we do not want to wrap commands
|
/* If this is a thread safe context, we do not want to wrap commands
|
||||||
@ -1218,6 +1217,7 @@ int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...)
|
|||||||
/* Release the argv. */
|
/* Release the argv. */
|
||||||
for (j = 0; j < argc; j++) decrRefCount(argv[j]);
|
for (j = 0; j < argc; j++) decrRefCount(argv[j]);
|
||||||
zfree(argv);
|
zfree(argv);
|
||||||
|
server.dirty++;
|
||||||
return REDISMODULE_OK;
|
return REDISMODULE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1236,6 +1236,7 @@ int RM_ReplicateVerbatim(RedisModuleCtx *ctx) {
|
|||||||
alsoPropagate(ctx->client->cmd,ctx->client->db->id,
|
alsoPropagate(ctx->client->cmd,ctx->client->db->id,
|
||||||
ctx->client->argv,ctx->client->argc,
|
ctx->client->argv,ctx->client->argc,
|
||||||
PROPAGATE_AOF|PROPAGATE_REPL);
|
PROPAGATE_AOF|PROPAGATE_REPL);
|
||||||
|
server.dirty++;
|
||||||
return REDISMODULE_OK;
|
return REDISMODULE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2265,8 +2265,9 @@ void call(client *c, int flags) {
|
|||||||
propagate_flags &= ~PROPAGATE_AOF;
|
propagate_flags &= ~PROPAGATE_AOF;
|
||||||
|
|
||||||
/* Call propagate() only if at least one of AOF / replication
|
/* Call propagate() only if at least one of AOF / replication
|
||||||
* propagation is needed. */
|
* propagation is needed. Note that modules commands handle replication
|
||||||
if (propagate_flags != PROPAGATE_NONE)
|
* in an explicit way, so we never replicate them automatically. */
|
||||||
|
if (propagate_flags != PROPAGATE_NONE && !(c->cmd->flags & CMD_MODULE))
|
||||||
propagate(c->cmd,c->db->id,c->argv,c->argc,propagate_flags);
|
propagate(c->cmd,c->db->id,c->argv,c->argc,propagate_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user