mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
On LUA script timeout, print the script SHA to the log
since the slowlog and other means that can help you detect the bad script are only exposed after the script is done. it might be a good idea to at least print the script name (sha) to the log when it timeouts.
This commit is contained in:
parent
40acb4412d
commit
98426e9886
@ -1083,6 +1083,7 @@ void scriptingInit(int setup) {
|
||||
if (setup) {
|
||||
server.lua_client = NULL;
|
||||
server.lua_caller = NULL;
|
||||
server.lua_cur_script = NULL;
|
||||
server.lua_timedout = 0;
|
||||
ldbInit();
|
||||
}
|
||||
@ -1407,7 +1408,11 @@ void luaMaskCountHook(lua_State *lua, lua_Debug *ar) {
|
||||
/* Set the timeout condition if not already set and the maximum
|
||||
* execution time was reached. */
|
||||
if (elapsed >= server.lua_time_limit && server.lua_timedout == 0) {
|
||||
serverLog(LL_WARNING,"Lua slow script detected: still in execution after %lld milliseconds. You can try killing the script using the SCRIPT KILL command.",elapsed);
|
||||
serverLog(LL_WARNING,
|
||||
"Lua slow script detected: still in execution after %lld milliseconds. "
|
||||
"You can try killing the script using the SCRIPT KILL command. "
|
||||
"script SHA is: %s",
|
||||
elapsed, server.lua_cur_script);
|
||||
server.lua_timedout = 1;
|
||||
/* Once the script timeouts we reenter the event loop to permit others
|
||||
* to call SCRIPT KILL or SHUTDOWN NOSAVE if needed. For this reason
|
||||
@ -1524,6 +1529,7 @@ void evalGenericCommand(client *c, int evalsha) {
|
||||
* If we are debugging, we set instead a "line" hook so that the
|
||||
* debugger is call-back at every line executed by the script. */
|
||||
server.lua_caller = c;
|
||||
server.lua_cur_script = funcname + 2;
|
||||
server.lua_time_start = mstime();
|
||||
server.lua_kill = 0;
|
||||
if (server.lua_time_limit > 0 && ldb.active == 0) {
|
||||
@ -1550,6 +1556,7 @@ void evalGenericCommand(client *c, int evalsha) {
|
||||
queueClientForReprocessing(server.master);
|
||||
}
|
||||
server.lua_caller = NULL;
|
||||
server.lua_cur_script = NULL;
|
||||
|
||||
/* Call the Lua garbage collector from time to time to avoid a
|
||||
* full cycle performed by Lua, which adds too latency.
|
||||
|
@ -1389,6 +1389,7 @@ struct redisServer {
|
||||
lua_State *lua; /* The Lua interpreter. We use just one for all clients */
|
||||
client *lua_client; /* The "fake client" to query Redis from Lua */
|
||||
client *lua_caller; /* The client running EVAL right now, or NULL */
|
||||
char* lua_cur_script; /* The current script right now, or NULL */
|
||||
dict *lua_scripts; /* A dictionary of SHA1 -> Lua scripts */
|
||||
unsigned long long lua_scripts_mem; /* Cached scripts' memory + oh */
|
||||
mstime_t lua_time_limit; /* Script timeout in milliseconds */
|
||||
|
Loading…
Reference in New Issue
Block a user