From d4a35f5b65dea20d990b8a82835396bbca5cfb52 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 20 Apr 2018 15:39:11 +0100 Subject: [PATCH] [Feature] Try harder to upload scripts to the Redis server Issue: #2186 --- lualib/lua_redis.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua index bb229479c..d22a4010c 100644 --- a/lualib/lua_redis.lua +++ b/lualib/lua_redis.lua @@ -812,6 +812,7 @@ local function load_script_taskless(script, cfg, ev_base) "uploaded redis script to %s with id %s, sha: %s", opt.upstream:get_addr(), script.id, data) script.sha = data -- We assume that sha is the same on all servers + script.fatal_error = nil end script.in_flight = script.in_flight - 1 @@ -851,7 +852,16 @@ local function add_redis_script(script, redis_params) -- Register on load function rspamd_config:add_on_load(function(cfg, ev_base, worker) - load_redis_script(new_script, cfg, ev_base, worker) + local mult = 0.0 + rspamd_config:add_periodic(ev_base, 0.0, function() + if not new_script.sha then + load_redis_script(new_script, cfg, ev_base, worker) + mult = mult + 1 + return 1.0 * mult -- Check one more time in one second + end + + return false + end, false) end) table.insert(redis_scripts, new_script) -- 2.39.5