Skip to content

Commit

Permalink
Avoid defragging scripts during EVAL command execution (valkey-io#1414)
Browse files Browse the repository at this point in the history
This can happen when scripts are running for long period of time and the server attempts to defrag it in the whileBlockedCron.

Signed-off-by: Ran Shidlansik <[email protected]>
  • Loading branch information
ranshid authored Dec 12, 2024
1 parent 5f7fe9e commit 2d92404
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/defrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*/

#include "server.h"
#include "script.h"
#include <stddef.h>

#ifdef HAVE_DEFRAG
Expand Down Expand Up @@ -1050,6 +1051,9 @@ static doneStatus defragLuaScripts(monotime endtime, void *target, void *privdat
UNUSED(target);
UNUSED(privdata);
if (endtime == 0) return DEFRAG_NOT_DONE; // required initialization
/* In case we are in the process of eval some script we do not want to replace the script being run
* so we just bail out without really defragging here. */
if (scriptIsRunning()) return DEFRAG_DONE;
activeDefragSdsDict(evalScriptsDict(), DEFRAG_SDS_DICT_VAL_LUA_SCRIPT);
return DEFRAG_DONE;
}
Expand Down

0 comments on commit 2d92404

Please sign in to comment.