From 60d5ef4d828bc8732ac1d4c274471655a13d667d Mon Sep 17 00:00:00 2001 From: sundb Date: Thu, 25 Feb 2021 00:45:13 +0800 Subject: [PATCH] Use addReplyErrorObject with shared.noscripterr (#8544) --- src/scripting.c | 4 ++-- tests/unit/info.tcl | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/scripting.c b/src/scripting.c index 7bf9f1c04..6830e7a70 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -1544,7 +1544,7 @@ void evalGenericCommand(client *c, int evalsha) { * return an error. */ if (evalsha) { lua_pop(lua,1); /* remove the error handler from the stack. */ - addReply(c, shared.noscripterr); + addReplyErrorObject(c, shared.noscripterr); return; } if (luaCreateFunction(c,lua,c->argv[1]) == NULL) { @@ -1695,7 +1695,7 @@ void evalShaCommand(client *c) { * not the right length. So we return an error ASAP, this way * evalGenericCommand() can be implemented without string length * sanity check */ - addReply(c, shared.noscripterr); + addReplyErrorObject(c, shared.noscripterr); return; } if (!(c->flags & CLIENT_LUA_DEBUG)) diff --git a/tests/unit/info.tcl b/tests/unit/info.tcl index 08171fff9..0602e7147 100644 --- a/tests/unit/info.tcl +++ b/tests/unit/info.tcl @@ -62,6 +62,19 @@ start_server {tags {"info"}} { assert_equal [s total_error_replies] 2 } + test {errorstats: failed call NOSCRIPT error} { + r config resetstat + assert_equal [s total_error_replies] 0 + assert_match {} [errorstat NOSCRIPT] + catch {r evalsha NotValidShaSUM 0} e + assert_match {NOSCRIPT*} $e + assert_match {*count=1*} [errorstat NOSCRIPT] + assert_match {*calls=1,*,rejected_calls=0,failed_calls=1} [cmdstat evalsha] + assert_equal [s total_error_replies] 1 + r config resetstat + assert_match {} [errorstat NOSCRIPT] + } + test {errorstats: failed call NOGROUP error} { r config resetstat assert_match {} [errorstat NOGROUP]