Fix issue where error replies are not counted on stats (#8659)
lookupKeyReadOrReply and lookupKeyWriteOrReply might decide to reply to the user with the given robj reply. This reply might be an error reply and if so addReply function is used instead of addReplyErrorObject which will cause the error reply not to be counted on stats. The fix checks the first char in the reply and if its '-' (error) it uses addReplyErrorObject.
This commit is contained in:
parent
18b59f35ef
commit
95360c2e0c
14
src/db.c
14
src/db.c
@ -164,16 +164,24 @@ 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){
|
||||
serverAssert(sdsEncodedObject(reply));
|
||||
sds rep = reply->ptr;
|
||||
if (sdslen(rep) > 1 && rep[0] == '-'){
|
||||
addReplyErrorObject(c, reply);
|
||||
} else {
|
||||
addReply(c,reply);
|
||||
}
|
||||
}
|
||||
robj *lookupKeyReadOrReply(client *c, robj *key, robj *reply) {
|
||||
robj *o = lookupKeyRead(c->db, key);
|
||||
if (!o) addReply(c,reply);
|
||||
if (!o) SentReplyOnKeyMiss(c, reply);
|
||||
return o;
|
||||
}
|
||||
|
||||
robj *lookupKeyWriteOrReply(client *c, robj *key, robj *reply) {
|
||||
robj *o = lookupKeyWrite(c->db, key);
|
||||
if (!o) addReply(c,reply);
|
||||
if (!o) SentReplyOnKeyMiss(c, reply);
|
||||
return o;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user