aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-12-19 15:13:23 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-12-19 15:13:23 +0000
commitd35385f951ee38dfdd0bedc77eb7e2d1e5809e40 (patch)
tree4a921f89b266414794222f3f21434970a3bcfc46
parentde56620e125e27062248272b2028602d1e71b01c (diff)
downloadrspamd-d35385f951ee38dfdd0bedc77eb7e2d1e5809e40.tar.gz
rspamd-d35385f951ee38dfdd0bedc77eb7e2d1e5809e40.zip
[Minor] Fix race condition when uploading redis scripts
-rw-r--r--lualib/lua_redis.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua
index 2a917b56c..48ea1b6ed 100644
--- a/lualib/lua_redis.lua
+++ b/lualib/lua_redis.lua
@@ -1140,7 +1140,7 @@ local function script_set_loaded(script)
script.loaded = true
end
- script.servers_ready = nil -- Allow further reload
+ script.pending_upload = false -- Allow further reload
local wait_table = {}
for _, s in ipairs(script.waitq) do
@@ -1267,6 +1267,7 @@ local function load_script_task(script, task, is_write)
if is_all_servers_ready(script) then
script_set_loaded(script)
elseif is_all_servers_failed(script) then
+ script.pending_upload = false
script.fatal_error = "cannot upload script to any server"
end
end -- callback
@@ -1284,6 +1285,7 @@ local function load_script_task(script, task, is_write)
if is_all_servers_ready(script) then
script_set_loaded(script)
elseif is_all_servers_failed(script) then
+ script.pending_upload = false
script.fatal_error = "cannot upload script to any server"
end
end
@@ -1331,6 +1333,7 @@ local function load_script_taskless(script, cfg, ev_base, is_write)
if is_all_servers_ready(script) then
script_set_loaded(script)
elseif is_all_servers_failed(script) then
+ script.pending_upload = false
script.fatal_error = "cannot upload script to any server"
end
end
@@ -1348,6 +1351,7 @@ local function load_script_taskless(script, cfg, ev_base, is_write)
if is_all_servers_ready(script) then
script_set_loaded(script)
elseif is_all_servers_failed(script) then
+ script.pending_upload = false
script.fatal_error = "cannot upload script " .. script_description(script) .. " to any server"
end
end
@@ -1466,12 +1470,13 @@ local function exec_redis_script(id, params, callback, keys, args)
-- Schedule restart if possible
if can_reload then
table.insert(script.waitq, do_call)
- if not script.servers_ready then
+ if not script.pending_upload 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
+ script.pending_upload = true
-- Reload scripts if this has not been initiated yet
if params.task then
load_script_task(script, params.task)