]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Do not enable HS cleanup when disable_hyperscan is set
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 27 Feb 2026 11:01:13 +0000 (11:01 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 27 Feb 2026 11:01:13 +0000 (11:01 +0000)
When disable_hyperscan is true, workers skip loading hyperscan databases
and never notify main about known cache files. This caused main to delete
all cached .hs.zst files on exit since none were marked as "known".
Also promote worker hyperscan notification to info log level.

src/libserver/rspamd_control.c
src/libserver/worker_util.c

index a5c603c4b05443c3814192a6e03eaa0a2d8fb7a1..d9c6ccb91151a49bfd00e853f2ee8f3e62aab32b 100644 (file)
@@ -1162,8 +1162,16 @@ rspamd_srv_handler(EV_P_ ev_io *w, int revents)
                                else {
                                        /* Legacy full cache update */
 
-                                       /* After getting this notice, we can clean up old hyperscan files */
-                                       rspamd_hyperscan_notice_loaded();
+                                       /*
+                                        * Only enable cleanup if hyperscan is not disabled.
+                                        * When disable_hyperscan is set, workers won't load databases
+                                        * and thus won't notify main about known files via
+                                        * RSPAMD_SRV_NOTICE_HYPERSCAN_CACHE. Enabling cleanup in that
+                                        * case would cause main to delete all cached files on exit.
+                                        */
+                                       if (!rspamd_main->cfg->disable_hyperscan) {
+                                               rspamd_hyperscan_notice_loaded();
+                                       }
 
                                        msg_info_main("received hyperscan cache loaded");
 
index 35700fb325aae88b0c4755f31e8b503d2c981b20..7b4165cfe515bc7b9db5e6c54c1d9d26ac6ed6ae 100644 (file)
@@ -2088,12 +2088,11 @@ rspamd_worker_hyperscan_ready(struct rspamd_main *rspamd_main,
        rep.type = RSPAMD_CONTROL_HYPERSCAN_LOADED;
        rep.id = cmd->id;
 
-       msg_debug_hyperscan("received hyperscan loaded notification, forced=%d",
-                                               cmd->cmd.hs_loaded.forced);
+       msg_info("received hyperscan loaded notification, forced=%d",
+                        cmd->cmd.hs_loaded.forced);
 
        /* All file operations go through Lua backend */
        g_assert(rspamd_hs_cache_has_lua_backend());
-       msg_debug_hyperscan("using async backend-based hyperscan loading");
        rspamd_re_cache_load_hyperscan_scoped_async(cache, worker->srv->event_loop,
                                                                                                cache_dir, false);
        rep.reply.hs_loaded.status = 0;