This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit ed24b49133a06a5f33da0880d546296ce6d714ff Author: Quan Tran <hqt...@linagora.com> AuthorDate: Fri Mar 28 15:16:48 2025 +0700 JAMES-4124 Rspamd + Kvrocks Sentinel: fix `lua_bayes_redis.lua:145: cannot get bayes statistics for BAYES_HAM: READONLY You can't write against a read only slave` error Despite Rspamd acked correctly about the master/replicas Kvrocks endpoint thanks to Sentinel. Reason: Rspamd tried to execute the following readonly Lua Script using EVALSHA command against the Kvrocks replicas which has been strictly rejected by Kvrocks replicas (while Redis replicas accepts read-only Lua scripts): ```lua local cursor = tonumber(KEYS[1]) local ret = redis.call('SSCAN', KEYS[2] .. '_keys', cursor, 'COUNT', tonumber(KEYS[4])) local new_cursor = tonumber(ret[1]) local nkeys = #ret[2] local learns = 0 for _, key in ipairs(ret[2]) do learns = learns + (tonumber(redis.call('HGET', key, KEYS[3])) or 0) end return { new_cursor, nkeys, learns } ``` --- .../rspamd/docker-compose-rspamd-with-kvrocks-sentinel.yml | 2 +- .../kvrocks/sentinel/master-node/kvrocks.conf | 8 ++++++++ .../kvrocks/sentinel/replica-node/kvrocks.conf | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/third-party/rspamd/docker-compose-rspamd-with-kvrocks-sentinel.yml b/third-party/rspamd/docker-compose-rspamd-with-kvrocks-sentinel.yml index 2150f27f67..ac452f3877 100644 --- a/third-party/rspamd/docker-compose-rspamd-with-kvrocks-sentinel.yml +++ b/third-party/rspamd/docker-compose-rspamd-with-kvrocks-sentinel.yml @@ -103,7 +103,7 @@ services: kvrocks-master: condition: service_healthy container_name: rspamd - image: rspamd/rspamd:3.9.1 + image: rspamd/rspamd:3.11.1 # Rspamd version >= 3.10 is needed to fix the Redis read-only issue when Rspamd gets bayes statistics too. environment: - RSPAMD_PASSWORD=admin volumes: diff --git a/third-party/rspamd/sample-configuration/kvrocks/sentinel/master-node/kvrocks.conf b/third-party/rspamd/sample-configuration/kvrocks/sentinel/master-node/kvrocks.conf index 88d6b4ec05..11212283a7 100644 --- a/third-party/rspamd/sample-configuration/kvrocks/sentinel/master-node/kvrocks.conf +++ b/third-party/rspamd/sample-configuration/kvrocks/sentinel/master-node/kvrocks.conf @@ -2,3 +2,11 @@ log-level info requirepass secret1 masterauth secret1 port 6379 + +# Fix Rspamd error: `lua_bayes_redis.lua:145: cannot get bayes statistics for BAYES_HAM: READONLY You can't write against a read only slave.`, despite Rspamd acked correctly the master/replicas Kvrock. +# Rationale: Rspamd relies on read-only Lua script to get BAYES statistics and execute the script against the Kvrocks replicas. +# Howver, Kvrocks replica stricly prohibits EVALSHA for even read-only Lua script - which is not the case with Redis replicas. +# This allows Rspamd to execute EVALSHA read-only Lua script on Kvrocks replicas to get the BAYES statistics. +# Cautious: This would allow Kvrocks replicas to be writable, therefore we need to carefully configure Rspamd or whatever app to use the correct master/replicas Kvrocks endpoints. +# There is also a small time window upon Redis Sentinel failover that Rspamd could write to the old master (new replica). We could very likely accept that for spam learning data. +slave-read-only no \ No newline at end of file diff --git a/third-party/rspamd/sample-configuration/kvrocks/sentinel/replica-node/kvrocks.conf b/third-party/rspamd/sample-configuration/kvrocks/sentinel/replica-node/kvrocks.conf index bea269d1dd..56a34f8d9b 100644 --- a/third-party/rspamd/sample-configuration/kvrocks/sentinel/replica-node/kvrocks.conf +++ b/third-party/rspamd/sample-configuration/kvrocks/sentinel/replica-node/kvrocks.conf @@ -3,3 +3,11 @@ slaveof kvrocks-master 6379 masterauth secret1 requirepass secret1 port 6379 + +# Fix Rspamd error: `lua_bayes_redis.lua:145: cannot get bayes statistics for BAYES_HAM: READONLY You can't write against a read only slave.`, despite Rspamd acked correctly the master/replicas Kvrock. +# Rationale: Rspamd relies on read-only Lua script to get BAYES statistics and execute the script against the Kvrocks replicas. +# Howver, Kvrocks replica stricly prohibits EVALSHA for even read-only Lua script - which is not the case with Redis replicas. +# This allows Rspamd to execute EVALSHA read-only Lua script on Kvrocks replicas to get the BAYES statistics. +# Cautious: This would allow Kvrocks replicas to be writable, therefore we need to carefully configure Rspamd or whatever app to use the correct master/replicas Kvrocks endpoints. +# There is also a small time window upon Redis Sentinel failover that Rspamd could write to the old master (new replica). We could very likely accept that for spam learning data. +slave-read-only no --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org