Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
cd2ee8b1
Unverified
Commit
cd2ee8b1
authored
Oct 01, 2018
by
Salvatore Sanfilippo
Committed by
GitHub
Oct 01, 2018
Browse files
Merge pull request #5396 from oranagra/cmdstats_exec
fix #5024 - commandstats for multi-exec were logged as EXEC.
parents
1da93f85
f03aed3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/server.c
View file @
cd2ee8b1
...
@@ -2408,6 +2408,7 @@ void preventCommandReplication(client *c) {
...
@@ -2408,6 +2408,7 @@ void preventCommandReplication(client *c) {
void
call
(
client
*
c
,
int
flags
)
{
void
call
(
client
*
c
,
int
flags
)
{
long
long
dirty
,
start
,
duration
;
long
long
dirty
,
start
,
duration
;
int
client_old_flags
=
c
->
flags
;
int
client_old_flags
=
c
->
flags
;
struct
redisCommand
*
real_cmd
=
c
->
cmd
;
/* Sent the command to clients in MONITOR mode, only if the commands are
/* Sent the command to clients in MONITOR mode, only if the commands are
* not generated from reading an AOF. */
* not generated from reading an AOF. */
...
@@ -2456,8 +2457,11 @@ void call(client *c, int flags) {
...
@@ -2456,8 +2457,11 @@ void call(client *c, int flags) {
slowlogPushEntryIfNeeded
(
c
,
c
->
argv
,
c
->
argc
,
duration
);
slowlogPushEntryIfNeeded
(
c
,
c
->
argv
,
c
->
argc
,
duration
);
}
}
if
(
flags
&
CMD_CALL_STATS
)
{
if
(
flags
&
CMD_CALL_STATS
)
{
c
->
lastcmd
->
microseconds
+=
duration
;
/* use the real command that was executed (cmd and lastamc) may be
c
->
lastcmd
->
calls
++
;
* different, in case of MULTI-EXEC or re-written commands such as
* EXPIRE, GEOADD, etc. */
real_cmd
->
microseconds
+=
duration
;
real_cmd
->
calls
++
;
}
}
/* Propagate the command into the AOF and replication link */
/* Propagate the command into the AOF and replication link */
...
...
tests/unit/introspection-2.tcl
View file @
cd2ee8b1
proc cmdstat
{
cmd
}
{
if
{[
regexp
"
\r\n
cmdstat_
$cmd:
(.*?)
\r\n
"
[
r info commandstats
]
_ value
]}
{
set _ $value
}
}
start_server
{
tags
{
"introspection"
}}
{
start_server
{
tags
{
"introspection"
}}
{
test
{
TTL and TYPYE do not alter the last access time of a key
}
{
test
{
TTL and TYPYE do not alter the last access time of a key
}
{
r set foo bar
r set foo bar
...
@@ -20,4 +26,55 @@ start_server {tags {"introspection"}} {
...
@@ -20,4 +26,55 @@ start_server {tags {"introspection"}} {
r set key2 2
r set key2 2
r touch key0 key1 key2 key3
r touch key0 key1 key2 key3
}
2
}
2
test
{
command stats for GEOADD
}
{
r config resetstat
r GEOADD foo 0 0 bar
assert_match
{
*calls=1,*
}
[
cmdstat geoadd
]
assert_match
{}
[
cmdstat zadd
]
}
test
{
command stats for EXPIRE
}
{
r config resetstat
r SET foo bar
r EXPIRE foo 0
assert_match
{
*calls=1,*
}
[
cmdstat expire
]
assert_match
{}
[
cmdstat del
]
}
test
{
command stats for BRPOP
}
{
r config resetstat
r LPUSH list foo
r BRPOP list 0
assert_match
{
*calls=1,*
}
[
cmdstat brpop
]
assert_match
{}
[
cmdstat rpop
]
}
test
{
command stats for MULTI
}
{
r config resetstat
r MULTI
r set foo bar
r GEOADD foo2 0 0 bar
r EXPIRE foo2 0
r EXEC
assert_match
{
*calls=1,*
}
[
cmdstat multi
]
assert_match
{
*calls=1,*
}
[
cmdstat exec
]
assert_match
{
*calls=1,*
}
[
cmdstat set
]
assert_match
{
*calls=1,*
}
[
cmdstat expire
]
assert_match
{
*calls=1,*
}
[
cmdstat geoadd
]
}
test
{
command stats for scripts
}
{
r config resetstat
r set mykey myval
r eval
{
redis.call
(
'set', KEYS
[
1
]
, 0
)
redis.call
(
'expire', KEYS
[
1
]
, 0
)
redis.call
(
'geoadd', KEYS
[
1
]
, 0, 0,
"bar"
)
}
1 mykey
assert_match
{
*calls=1,*
}
[
cmdstat eval
]
assert_match
{
*calls=2,*
}
[
cmdstat set
]
assert_match
{
*calls=1,*
}
[
cmdstat expire
]
assert_match
{
*calls=1,*
}
[
cmdstat geoadd
]
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment