Commit 27db4563 authored by antirez's avatar antirez
Browse files

Update cached time during slow scripts & transactions

Commands may use cached time when the precision is not vital. It is
a good idea to refresh it from time to time during the execution of long
running scripts or transactions composed of quite a lot of commands.
parent e64d0890
...@@ -162,6 +162,10 @@ void execCommand(redisClient *c) { ...@@ -162,6 +162,10 @@ void execCommand(redisClient *c) {
c->mstate.commands[j].argc = c->argc; c->mstate.commands[j].argc = c->argc;
c->mstate.commands[j].argv = c->argv; c->mstate.commands[j].argv = c->argv;
c->mstate.commands[j].cmd = c->cmd; c->mstate.commands[j].cmd = c->cmd;
/* From time to time, update the cached time so that if the transaction
* is huge, we'll have a chance to have more updated time info. */
if (j && j % 10000) updateCachedTime();
} }
c->argv = orig_argv; c->argv = orig_argv;
c->argc = orig_argc; c->argc = orig_argc;
......
...@@ -546,7 +546,8 @@ void luaMaskCountHook(lua_State *lua, lua_Debug *ar) { ...@@ -546,7 +546,8 @@ void luaMaskCountHook(lua_State *lua, lua_Debug *ar) {
REDIS_NOTUSED(ar); REDIS_NOTUSED(ar);
REDIS_NOTUSED(lua); REDIS_NOTUSED(lua);
elapsed = mstime() - server.lua_time_start; updateCachedTime();
elapsed = server.mstime - server.lua_time_start;
if (elapsed >= server.lua_time_limit && server.lua_timedout == 0) { if (elapsed >= server.lua_time_limit && server.lua_timedout == 0) {
redisLog(REDIS_WARNING,"Lua slow script detected: still in execution after %lld milliseconds. You can try killing the script using the SCRIPT KILL command.",elapsed); redisLog(REDIS_WARNING,"Lua slow script detected: still in execution after %lld milliseconds. You can try killing the script using the SCRIPT KILL command.",elapsed);
server.lua_timedout = 1; server.lua_timedout = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment