diff options
author | teplynin <35330419+teplynin@users.noreply.github.com> | 2024-12-15 12:54:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-15 12:54:16 +0300 |
commit | 4c45f5b1c800d3bb856091b0efc8a2b12108e08a (patch) | |
tree | 743293464884e9199ef36d35923d31ae5e4c02ce | |
parent | e40cbf34c84059df4290d3ab1d669cf81c194ea5 (diff) | |
parent | 16957bfccc4ce6b131bff2cb73ce433611233f9c (diff) | |
download | rspamd-4c45f5b1c800d3bb856091b0efc8a2b12108e08a.tar.gz rspamd-4c45f5b1c800d3bb856091b0efc8a2b12108e08a.zip |
Merge branch 'rspamd:master' into fix-rbl-check_received
-rw-r--r-- | lualib/lua_redis.lua | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua index 7b85f44c4..2a917b56c 100644 --- a/lualib/lua_redis.lua +++ b/lualib/lua_redis.lua @@ -1140,6 +1140,8 @@ local function script_set_loaded(script) script.loaded = true end + script.servers_ready = nil -- Allow further reload + local wait_table = {} for _, s in ipairs(script.waitq) do table.insert(wait_table, s) @@ -1461,20 +1463,25 @@ local function exec_redis_script(id, params, callback, keys, args) if not err then callback(err, data) elseif string.match(err, 'NOSCRIPT') then - -- Schedule restart - logger.infox(params.task or rspamd_config, - 'redis script %s is not loaded (NOSCRIPT returned), scheduling reload', - script_description(script)) - script.sha = nil + -- Schedule restart if possible if can_reload then table.insert(script.waitq, do_call) if not script.servers_ready then + logger.infox(params.task or rspamd_config, + 'redis script %s is not loaded (NOSCRIPT returned), scheduling reload', + script_description(script)) + script.sha = nil + script.loaded = nil -- Reload scripts if this has not been initiated yet if params.task then load_script_task(script, params.task) else load_script_taskless(script, rspamd_config, params.ev_base) end + else + logger.infox(params.task or rspamd_config, + 'redis script %s is not ready (NOSCRIPT returned), waiting it to be loaded', + script_description(script)) end else callback(err, data) @@ -1512,24 +1519,24 @@ local function exec_redis_script(id, params, callback, keys, args) end end - if script.loaded then + if script.loaded and script.sha then do_call(true) else - -- Delayed until scripts are loaded - logger.infox(params.task or rspamd_config, 'redis script %s is not loaded, trying to load', - script_description(script)) - if not params.task then - table.insert(script.waitq, do_call) + table.insert(script.waitq, do_call) + if not script.servers_ready then + -- Delayed until scripts are loaded + logger.infox(params.task or rspamd_config, 'redis script %s is not loaded, trying to load', + script_description(script)) + -- Reload scripts if this has not been initiated yet + if params.task then + load_script_task(script, params.task) + else + load_script_taskless(script, rspamd_config, params.ev_base) + end else - -- TODO: fix taskfull requests - table.insert(script.waitq, function() - if script.loaded then - do_call(false) - else - callback('NOSCRIPT', nil) - end - end) - load_script_task(script, params.task, params.is_write) + -- Already loaded, but not yet ready + logger.infox(params.task or rspamd_config, 'redis script %s is not ready, waiting it to be loaded', + script_description(script)) end end |