File explosion in spam folder on server

I was having problems with sa-learn chewing tons of cpu, which I fixed by renicing it, but I had noticed Apple Mail constantly saying things like “moving 3 of 11,000 messages” when I had not asked it to do any such thing. My spam folder (that I see from Mail through IMAP) only has a couple of hundred messages in it, but if I look in /home/user-data/mail/mailboxes/example.com/marcus/.Spam/cur/ on the server, there are 1.1 million messages. I can see the same numbers if I look at the “Account info” panel in Mail. I picked one at random, and grepped for its message-id (which I would expect to be unique) in the same folder, only to find that there are thousands of duplicates of this same message.

I don’t know what the components of the message filenames are, but they are like this:

/home/user-data/mail/mailboxes/example.com/marcus/.Spam/cur/1720817676.M740874P129203.mail.example.com,S=9020,W=9146:2,Saf

The messages mostly have the same 17208... number, but the M74... number changes.

I deleted everything in this spam folder and it freed up 10G of disk space!

Now it’s a bit quieter, I did some more searching and found that across all users in all domains there are only 27,000 spam messages, so this was clearly an anomaly.

So, any idea what might be responsible for this file explosion? Anyone else seen large message counts in Apple Mail?

I just got the same issue. 600,000+ messages just started being there.
Is it possible that MiaB is not actually deleting messages? And now the client is recognizing them as there?