On 10/30/25 11:19 AM, Jess Robinson wrote:
Hi all,

Asking here before I report a bug / attempt a patch.

We noticed that with bayes_auto_expire set to true, using a MySQL bayes store, 
the auto-expiry does not run. The system has been up for several months, and 
the bayes_expire table remains empty. Manual --force-expire via sa-learn works 
ok once tried.

Version: SA 4.0.0
Scanning via exim / spamc
Manual spam reporting: spamc -L

After a large amount of code reading yesterday, I think this is because the 
MySQL BayesStore does not implement get_storage_variables - 
https://github.com/apache/spamassassin/blob/9e1677a6b73dc163c97bf382d9767856fe3ccbef/lib/Mail/SpamAssassin/BayesStore.pm#L570

from Mail::SpamAssassin::Conf
       bayes_auto_expire             (default: 1)
           If enabled, the Bayes system will try to automatically expire old 
tokens from the database.  Auto-expiry occurs when the number of tokens in the 
database surpasses the bayes_expiry_max_db_size value.
           If a bayes datastore backend does not implement individual key/value 
expirations, the setting is silently ignored.

In MySQL storage, auto_expire has not been implemented, currently I am running 
"sa-learn --force-expire -u $user" for each user weekly.

 Cheers
  Giovanni

This is used in expiry_due in BayesStore: 
https://github.com/apache/spamassassin/blob/9e1677a6b73dc163c97bf382d9767856fe3ccbef/lib/Mail/SpamAssassin/BayesStore.pm#L462

which presumably dies instead.

It was expected to run given the docs in sa-learn 
https://spamassassin.apache.org/full/4.0.x/doc/sa-learn.html#EXPIRATION which 
do not mention any bayesstore exceptions.

Am I barking up the correct tree?

Separately: is auto_expire recommended, or should we be creating some sort of 
cronjob to run thousands of user expiry calls manually?

Thanks in advance,

Jess Robinson / Runbox (setting up per-user spam training)

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to