summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-10-09 11:01:41 +0200
committerantirez <antirez@gmail.com>2018-10-09 11:02:03 +0200
commit483496903293be2541c4b779674add12281c5059 (patch)
tree5c099312009f64c2d12ccec2b519c95f9f6f23a2
parent71c37605d011041c8de77ae2a65ef4af15438bb4 (diff)
downloadredis-queue-in-multi.tar.gz
Transactions: Use CMD_CLAL_NOQUEUE now that call() handles +QUEUED.queue-in-multi
-rw-r--r--src/multi.c2
-rw-r--r--src/scripting.c2
-rw-r--r--src/server.c11
-rw-r--r--src/server.h3
4 files changed, 14 insertions, 4 deletions
diff --git a/src/multi.c b/src/multi.c
index 112ce0605..9f789fa62 100644
--- a/src/multi.c
+++ b/src/multi.c
@@ -158,7 +158,7 @@ void execCommand(client *c) {
must_propagate = 1;
}
- call(c,CMD_CALL_FULL);
+ call(c,CMD_CALL_FULL|CMD_CALL_NOQUEUE);
/* Commands may alter argc/argv, restore mstate. */
c->mstate.commands[j].argc = c->argc;
diff --git a/src/scripting.c b/src/scripting.c
index 979156037..51a9f95dc 100644
--- a/src/scripting.c
+++ b/src/scripting.c
@@ -560,7 +560,7 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
}
/* Run the command */
- int call_flags = CMD_CALL_SLOWLOG | CMD_CALL_STATS;
+ int call_flags = CMD_CALL_SLOWLOG | CMD_CALL_STATS | CMD_CALL_NOQUEUE;
if (server.lua_replicate_commands) {
/* Set flags according to redis.set_repl() settings. */
if (server.lua_repl & PROPAGATE_AOF)
diff --git a/src/server.c b/src/server.c
index fd65bb182..b1865e530 100644
--- a/src/server.c
+++ b/src/server.c
@@ -2421,8 +2421,15 @@ void call(client *c, int flags) {
/* If the client is in the context of a transaction, reply with
* +QUEUED and just accumulate the command in the client transaction
- * commands vector. */
- if (c->flags & CLIENT_MULTI &&
+ * commands vector.
+ *
+ * Note that CALL_NOQUEUE can override this check and execute the command
+ * straight away even if the client is in "MULTI" state. This is useful
+ * every time we want to actually execute commands even if the client is
+ * in MULTI state, like in scripting.c or in the implementation of EXEC
+ * itself. */
+ if (!(flags & CMD_CALL_NOQUEUE) &&
+ c->flags & CLIENT_MULTI &&
c->cmd->proc != execCommand && c->cmd->proc != discardCommand &&
c->cmd->proc != multiCommand && c->cmd->proc != watchCommand)
{
diff --git a/src/server.h b/src/server.h
index 4c4c0ce55..a83908ce8 100644
--- a/src/server.h
+++ b/src/server.h
@@ -416,6 +416,9 @@ typedef long long mstime_t; /* millisecond time type. */
#define CMD_CALL_PROPAGATE_REPL (1<<3)
#define CMD_CALL_PROPAGATE (CMD_CALL_PROPAGATE_AOF|CMD_CALL_PROPAGATE_REPL)
#define CMD_CALL_FULL (CMD_CALL_SLOWLOG | CMD_CALL_STATS | CMD_CALL_PROPAGATE)
+/* --- call() special semantics that can be requested by the caller
+ * --- but are not included in CALL_FULL. */
+#define CMD_CALL_NOQUEUE (1<<4)
/* Command propagation flags, see propagate() function */
#define PROPAGATE_NONE 0