Avoid defragging scripts during EVAL command execution (#1414)

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 <ranshid@amazon.com>
This commit is contained in:
ranshid 2024-12-12 23:52:58 +02:00 committed by GitHub
parent 5f7fe9ef21
commit 2d92404522
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,6 +34,7 @@
*/
#include "server.h"
#include "script.h"
#include <stddef.h>
#ifdef HAVE_DEFRAG
@ -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;
}