From 1c77f69b16f675cf15a5ce5d038d07a831862dfb Mon Sep 17 00:00:00 2001 From: Karthik Subbarao Date: Mon, 20 May 2024 15:36:57 +0000 Subject: [PATCH] Update documentation, minor refactor, additional test case Signed-off-by: Karthik Subbarao --- src/script_lua.c | 2 +- src/server.h | 2 +- tests/unit/info.tcl | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/script_lua.c b/src/script_lua.c index 501116ae4f..eff914779d 100644 --- a/src/script_lua.c +++ b/src/script_lua.c @@ -639,7 +639,7 @@ static void luaReplyToRedisReply(client *c, client* script_client, lua_State *lu errorInfo err_info = {0}; luaExtractErrorInformation(lua, &err_info); addReplyErrorFormatEx(c, - err_info.ignore_err_stats_update? ERR_REPLY_FLAG_NO_STATS_UPDATE | ERR_REPLY_FLAG_LUA: ERR_REPLY_FLAG_LUA, + ERR_REPLY_FLAG_LUA | (err_info.ignore_err_stats_update? ERR_REPLY_FLAG_NO_STATS_UPDATE: 0), "-%s", err_info.msg); luaErrorInformationDiscard(&err_info); diff --git a/src/server.h b/src/server.h index b77ef69dfd..b9c9a00b4d 100644 --- a/src/server.h +++ b/src/server.h @@ -2564,7 +2564,7 @@ void serverSetCpuAffinity(const char *cpulist); /* ERROR STATS constants */ #define ERROR_STATS_LUA_LIMIT 128 /* After the errors RAX reaches this limit, instead of tracking - custom LUA errors, we track the error under `error_LUA_ERRORSTATS_OVERFLOW`. */ + custom LUA errors, we track the error under the symbol below. */ #define LUA_ERRORSTATS_OVERFLOW_ERR "LUA_ERRORSTATS_OVERFLOW" /* afterErrorReply flags */ diff --git a/tests/unit/info.tcl b/tests/unit/info.tcl index 6a7fbe9438..f72166ce32 100644 --- a/tests/unit/info.tcl +++ b/tests/unit/info.tcl @@ -278,7 +278,7 @@ start_server {tags {"info" "external:skip"}} { r config resetstat for {set j 1} {$j <= 1100} {incr j} { assert_error "$j my error message" { - r eval {return redis.error_reply(string.format('%s my error message', ARGV[1]))} 0 $j + r eval {return server.error_reply(string.format('%s my error message', ARGV[1]))} 0 $j } } # Validate that custom LUA errors are tracked in `LUA_ERRORSTATS_OVERFLOW` when errors @@ -287,6 +287,9 @@ start_server {tags {"info" "external:skip"}} { # Validate that non LUA errors continue to be tracked even when we have >=128 entries. assert_error {ERR syntax error} {r set a b c d e f g} assert_equal "count=1" [errorstat ERR] + r eval {return server.error_reply(string.format('My error message'))} 0 + r eval {return {err = 'My error message'}} 0 + assert_equal "count=974" [errorstat LUA_ERRORSTATS_OVERFLOW] } test {stats: eventloop metrics} {