summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-01-19 12:52:05 +0100
committerantirez <antirez@gmail.com>2013-01-19 12:55:12 +0100
commitdbde1d85ea63009f12ec164653eb994d07827276 (patch)
tree3026d7fcc7e2b4937a77f817898339a50127e453
parent560e049947779a7cae29c7bd924bd86834275022 (diff)
downloadredis-dbde1d85ea63009f12ec164653eb994d07827276.tar.gz
Slowlog: don't log EXEC but just the executed commands.
The Redis Slow Log always used to log the slow commands executed inside a MULTI/EXEC block. However also EXEC was logged at the end, which is perfectly useless. Now EXEC is no longer logged and a test was added to test this behavior. This fixes issue #759.
-rw-r--r--src/redis.c2
-rw-r--r--tests/unit/slowlog.tcl12
2 files changed, 13 insertions, 1 deletions
diff --git a/src/redis.c b/src/redis.c
index c2f40f7de..15ef74379 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -1510,7 +1510,7 @@ void call(redisClient *c, int flags) {
/* Log the command into the Slow log if needed, and populate the
* per-command statistics that we show in INFO commandstats. */
- if (flags & REDIS_CALL_SLOWLOG)
+ if (flags & REDIS_CALL_SLOWLOG && c->cmd->proc != execCommand)
slowlogPushEntryIfNeeded(c->argv,c->argc,duration);
if (flags & REDIS_CALL_STATS) {
c->cmd->microseconds += duration;
diff --git a/tests/unit/slowlog.tcl b/tests/unit/slowlog.tcl
index 2216e925a..b25b91e2c 100644
--- a/tests/unit/slowlog.tcl
+++ b/tests/unit/slowlog.tcl
@@ -55,4 +55,16 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
set e [lindex [r slowlog get] 0]
lindex $e 3
} {sadd set foo {AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... (1 more bytes)}}
+
+ test {SLOWLOG - EXEC is not logged, just executed commands} {
+ r config set slowlog-log-slower-than 100000
+ r slowlog reset
+ assert_equal [r slowlog len] 0
+ r multi
+ r debug sleep 0.2
+ r exec
+ assert_equal [r slowlog len] 1
+ set e [lindex [r slowlog get] 0]
+ assert_equal [lindex $e 3] {debug sleep 0.2}
+ }
}