]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Warn on task_timeout less than symcache symbol timeout
authorAlexander Moisseev <moiseev@mezonplus.ru>
Fri, 10 Apr 2026 08:25:44 +0000 (11:25 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Fri, 10 Apr 2026 10:00:06 +0000 (13:00 +0300)
Call rspamd_worker_check_and_adjust_timeout during configtest so
misconfigured plugin timeouts are reported at configuration validation
time. Elevate the diagnostic from info to warning level.

Fix rspamd_symcache_add_symbol_augmentation to parse "key=value" format
in augmentation strings, allowing numeric timeout augmentations from
Lua plugins to be stored and compared correctly.

Clarify mx_check timeout comment to explain that the effective symbol
timeout includes dns.timeout in addition to the configured value.

conf/modules.d/mx_check.conf
src/libserver/symcache/symcache_c.cxx
src/libserver/worker_util.c
src/rspamadm/configtest.c

index 2068fc575d2a868cc26271f7cb8381486b66a107..0993bc4526ab9d7e98b6535c38be325b806234e0 100644 (file)
@@ -21,7 +21,9 @@
 # You also need to define redis servers for this module
 
 mx_check {
-  # connection timeout in seconds
+  # TCP connection timeout in seconds. The effective symbol timeout is
+  # timeout + dns.timeout (see options.inc), so task_timeout must be set
+  # higher than their sum to avoid forced task termination.
   timeout = 1.0;
   # symbol yielded if no MX is connectable
   symbol_bad_mx = "MX_INVALID";
index a185305f9b59ef151a2c6ce064ada5baa28cce40..57a817031a006f435ad3104210d330abec276f9a 100644 (file)
@@ -104,6 +104,13 @@ bool rspamd_symcache_add_symbol_augmentation(struct rspamd_symcache *cache,
 
        /* Handle empty or absent strings equally */
        if (value == nullptr || value[0] == '\0') {
+               /* Check if augmentation uses "key=value" format */
+               const char *eq = strchr(augmentation, '=');
+               if (eq != nullptr && eq != augmentation && eq[1] != '\0') {
+                       return item->add_augmentation(*real_cache,
+                                                                                 std::string_view{augmentation, static_cast<size_t>(eq - augmentation)},
+                                                                                 std::string_view{eq + 1});
+               }
                return item->add_augmentation(*real_cache, augmentation, std::nullopt);
        }
 
index 2d62dc2b797d2fc2bf44ffbba530e32eb98d7644..63e0d1f545a89ecc1cb85165f62e0fd2f229d3b6 100644 (file)
@@ -2668,7 +2668,7 @@ rspamd_worker_check_and_adjust_timeout(struct rspamd_config *cfg, double timeout
        g_assert(tres != 0);
 
        if (tres->max_timeout > timeout) {
-               msg_info_config("configured task_timeout %.2f is less than maximum symbols cache timeout %.2f; "
+               msg_warn_config("configured task_timeout %.2f is less than maximum symbols cache timeout %.2f; "
                                                "some symbols can be terminated before checks",
                                                timeout, tres->max_timeout);
                GString *buf = g_string_sized_new(512);
@@ -2686,7 +2686,7 @@ rspamd_worker_check_and_adjust_timeout(struct rspamd_config *cfg, double timeout
                                                                          tres->items[i].timeout);
                        }
                }
-               msg_info_config("list of top %d symbols by execution time: %v",
+               msg_warn_config("list of top %d symbols by execution time: %v",
                                                (int) MIN(tres->nitems, max_displayed_items),
                                                buf);
 
index dae90eabd9b10455c85190f9add5a9896fcbcd23..de57efd32df356294a4475ef276ed64d88aded3b 100644 (file)
@@ -19,6 +19,7 @@
 #include "cfg_rcl.h"
 #include "rspamd.h"
 #include "lua/lua_common.h"
+#include "worker_util.h"
 
 static gboolean quiet = FALSE;
 static char *config = NULL;
@@ -153,6 +154,10 @@ rspamadm_configtest(int argc, char **argv, const struct rspamadm_command *cmd)
                        ret = FALSE;
                }
 
+               if (ret) {
+                       rspamd_worker_check_and_adjust_timeout(cfg, cfg->task_timeout);
+               }
+
                if (ret) {
                        if (rspamd_lua_require_function(cfg->lua_state, "lua_cfg_utils", "check_configuration_errors")) {
                                GError *err = NULL;