diff options
author | DarrenJiang13 <yjjiang1996@163.com> | 2021-08-07 10:27:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-06 19:27:24 -0700 |
commit | 43eb0ce3bf76a5d287b93a767bead9ad6230a1ad (patch) | |
tree | c172843107f7a9b8463f5f277f8b0b04a2461826 | |
parent | 0a9377535b6fd42ca6affa1c939fb859950d8043 (diff) | |
download | redis-43eb0ce3bf76a5d287b93a767bead9ad6230a1ad.tar.gz |
[BUGFIX] Add some missed error statistics (#9328)
add error counting for some missed behaviors.
-rw-r--r-- | src/db.c | 2 | ||||
-rw-r--r-- | src/multi.c | 10 | ||||
-rw-r--r-- | src/object.c | 3 | ||||
-rw-r--r-- | src/server.h | 1 | ||||
-rw-r--r-- | tests/unit/info.tcl | 7 |
5 files changed, 14 insertions, 9 deletions
@@ -165,7 +165,7 @@ robj *lookupKeyWriteWithFlags(redisDb *db, robj *key, int flags) { robj *lookupKeyWrite(redisDb *db, robj *key) { return lookupKeyWriteWithFlags(db, key, LOOKUP_NONE); } -static void SentReplyOnKeyMiss(client *c, robj *reply){ +void SentReplyOnKeyMiss(client *c, robj *reply){ serverAssert(sdsEncodedObject(reply)); sds rep = reply->ptr; if (sdslen(rep) > 1 && rep[0] == '-'){ diff --git a/src/multi.c b/src/multi.c index de871102a..56629fd80 100644 --- a/src/multi.c +++ b/src/multi.c @@ -179,9 +179,13 @@ void execCommand(client *c) { * A failed EXEC in the first case returns a multi bulk nil object * (technically it is not an error but a special behavior), while * in the second an EXECABORT error is returned. */ - if (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC)) { - addReply(c, c->flags & CLIENT_DIRTY_EXEC ? shared.execaborterr : - shared.nullarray[c->resp]); + if (c->flags & (CLIENT_DIRTY_CAS | CLIENT_DIRTY_EXEC)) { + if (c->flags & CLIENT_DIRTY_EXEC) { + addReplyErrorObject(c, shared.execaborterr); + } else { + addReply(c, shared.nullarray[c->resp]); + } + discardTransaction(c); return; } diff --git a/src/object.c b/src/object.c index 317e3bf56..b65430784 100644 --- a/src/object.c +++ b/src/object.c @@ -1402,8 +1402,7 @@ robj *objectCommandLookup(client *c, robj *key) { robj *objectCommandLookupOrReply(client *c, robj *key, robj *reply) { robj *o = objectCommandLookup(c,key); - - if (!o) addReply(c, reply); + if (!o) SentReplyOnKeyMiss(c, reply); return o; } diff --git a/src/server.h b/src/server.h index 7e76c0a0f..e45558f8e 100644 --- a/src/server.h +++ b/src/server.h @@ -2394,6 +2394,7 @@ robj *lookupKeyReadWithFlags(redisDb *db, robj *key, int flags); robj *lookupKeyWriteWithFlags(redisDb *db, robj *key, int flags); robj *objectCommandLookup(client *c, robj *key); robj *objectCommandLookupOrReply(client *c, robj *key, robj *reply); +void SentReplyOnKeyMiss(client *c, robj *reply); int objectSetLRUOrLFU(robj *val, long long lfu_freq, long long lru_idle, long long lru_clock, int lru_multiplier); #define LOOKUP_NONE 0 diff --git a/tests/unit/info.tcl b/tests/unit/info.tcl index c12ad23e2..6fafad398 100644 --- a/tests/unit/info.tcl +++ b/tests/unit/info.tcl @@ -110,11 +110,12 @@ start_server {tags {"info" "external:skip"}} { catch {r exec} e assert_match {EXECABORT*} $e assert_match {*count=1*} [errorstat ERR] - assert_equal [s total_error_replies] 1 + assert_match {*count=1*} [errorstat EXECABORT] + assert_equal [s total_error_replies] 2 assert_match {*calls=0,*,rejected_calls=1,failed_calls=0} [cmdstat set] assert_match {*calls=1,*,rejected_calls=0,failed_calls=0} [cmdstat multi] - assert_match {*calls=1,*,rejected_calls=0,failed_calls=0} [cmdstat exec] - assert_equal [s total_error_replies] 1 + assert_match {*calls=1,*,rejected_calls=0,failed_calls=1} [cmdstat exec] + assert_equal [s total_error_replies] 2 r config resetstat assert_match {} [errorstat ERR] } |