Hello.

I have a question about Mail::SpamAssassin::BayesStore::DBM (DB_File).
I am using it with Mail::SpamAssassin::Locker::Flock.

I think this module is implemented as follows
For reading, tie_db_readonly tie (no lock)
For writing, tie_db_writable flock LOCK_EX & tie

multi-process $sa->check or $sa->learn
or spamd prefork if started
Is there any problem with spamassassin not doing flock LOCK_SH for reads?
Am I missing something in my code reading?

I did a stress experiment on DB_File at hand.
Without flock LOCK_SH for reads, the process does not terminate abnormally and continues to run, but sometimes empty data is returned or data with half-key is returned. From this experiment, it seems that flock LOCK_SH is indeed necessary for reads.

https://metacpan.org/pod/DB_File#Locking:-The-Trouble-with-fd
The above also seems to assume that locking is required for reads as well.

Perhaps SpamAssassin is designed for single-process use?
(If so, this would conflict with the preforked spamd, which does not seem to have any special locking to prevent this on the spamd side.)

I would be very grateful if someone could give me an answer.

Thank you in advance.

Reply via email to