Nested MULTI/EXEC may replicate in different cases.

For example:
1. A module command called within a MULTI section.
2. A Lua script with replicate_commands() called within a MULTI section.
3. A module command called from a Lua script in the above context.
This commit is contained in:
Yossi Gottlieb
2017-11-22 15:09:30 +02:00
parent 57bd8feb8d
commit 2c70d28295
2 changed files with 10 additions and 0 deletions

View File

@ -1164,6 +1164,8 @@ int RM_ReplyWithDouble(RedisModuleCtx *ctx, double d) {
* in the context of a command execution. EXEC will be handled by the
* RedisModuleCommandDispatcher() function. */
void moduleReplicateMultiIfNeeded(RedisModuleCtx *ctx) {
/* Skip this if client explicitly wrap the command with MULTI */
if (ctx->client->flags & CLIENT_MULTI) return;
/* If we already emitted MULTI return ASAP. */
if (ctx->flags & REDISMODULE_CTX_MULTI_EMITTED) return;
/* If this is a thread safe context, we do not want to wrap commands