commit ff10dae: [Fix] ClickHouse cleanup of old partitions
Anton Yuzhaninov
citrin+git at citrin.ru
Thu Feb 10 20:14:06 UTC 2022
Author: Anton Yuzhaninov
Date: 2022-02-10 10:05:08 +0000
URL: https://github.com/rspamd/rspamd/commit/ff10dae97e5720fe600420450488d80cc272df0e (refs/pull/4074/head)
[Fix] ClickHouse cleanup of old partitions
If /var/lib/rspamd/clickhouse_retention_run is missing or has no
number cleanup was not performed because of a following Lua error:
lua_periodic_callback_error: call to periodic script (registered at clickhouse.lua:1531) failed: /usr/share/rspamd/plugins/clickhouse.lua:991: attempt to compare number with nil; trace: [1]:{/usr/share/rspamd/plugins/clickhouse.lua:1069 - <unknown> [Lua]};
---
src/plugins/lua/clickhouse.lua | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua
index 7a2e276ee..00a0fc738 100644
--- a/src/plugins/lua/clickhouse.lua
+++ b/src/plugins/lua/clickhouse.lua
@@ -988,6 +988,10 @@ local function get_last_removal_ago()
f:close()
end
+ if last_ts == nil or (last_ts + settings.retention.period) <= current_ts then
+ return write_ts_to_file() and 0
+ end
+
if last_ts > current_ts then
-- Clock skew detected, overwrite last_ts with current_ts and wait for the next
-- retention period
@@ -996,10 +1000,6 @@ local function get_last_removal_ago()
return write_ts_to_file() and -1
end
- if last_ts == nil or (last_ts + settings.retention.period) <= current_ts then
- return write_ts_to_file() and 0
- end
-
return (last_ts + settings.retention.period) - current_ts
end
More information about the Commits
mailing list