From 06a5619e16e85eac8dc3df6a5972ec82b28d11d0 Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Tue, 15 Jan 2019 16:58:29 +0800 Subject: [PATCH] scripting: flag lua_client as CLIENT_MULTI after redis.replicate_commands() immediately To avoid nested MULTI/EXEC, we check the lua_caller's flag, if we are in the MULTI context we flag the lua_client as CLIENT_MULTI, but it's not enough we shoud flag lua_client as CLIENT_MULTI after redis.replicate_commands() immediately or the first write command after redis.replicate_commands() cannot know it's in an transaction, I know the missing CLIENT_MULTI doesn't have any effect now, but it's a real bug and we should fix it, in case someday we allow some dangerous command like BLPOP. --- src/scripting.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/scripting.c b/src/scripting.c index 7cf21f408..76885a02b 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -703,6 +703,9 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) { { execCommandPropagateMulti(server.lua_caller); server.lua_multi_emitted = 1; + /* Now we are in the MULTI context, the lua_client should be + * flag as CLIENT_MULTI. */ + c->flags |= CLIENT_MULTI; } /* Run the command */