From b6cab88c1dfe74a745c2ca3fbf51c4a77a6c3481 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 5 Jul 2017 10:10:20 +0200 Subject: [PATCH] Modules: no MULTI/EXEC for commands replicated from async contexts. They are technically like commands executed from external clients one after the other, and do not constitute a single atomic entity. --- src/module.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/module.c b/src/module.c index d307a2b95..d6c831386 100644 --- a/src/module.c +++ b/src/module.c @@ -1163,7 +1163,12 @@ 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) { + /* 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 + * executed into MUTLI/EXEC, they are executed as single commands + * from an external client in essence. */ + if (ctx->flags & REDISMODULE_CTX_THREAD_SAFE) return; execCommandPropagateMulti(ctx->client); ctx->flags |= REDISMODULE_CTX_MULTI_EMITTED; } -- GitLab