OpenBSD's default maximum number of file descriptors is 1772. Postfix accepts mail and then writes the mail to disk, hence every incoming email uses at least one file descriptor and possibly more. This became a problem when sending out 100,000+ emails within a two hour period. The fix is simply to increase the maximum number of file descriptors to a reasonable number using the sysctl variable kern.maxfiles. When OBSD runs out of file descriptors, it logs an error message to /var/log/messages, something like "/bsd: file table full". Of course, I would only look in this log if something was obviously wrong... and in this case the exhibiting symptom was a little strange.

The symptom exhibited itself in our POP3 daemon. Whenever we were running a mass email campaign, several of our email users would start getting multiple copies of old email (anything still residing in their "cur" directory, maildir format). I thought at first this was an Outlook bug, or at least an Outlook/Dovecot bug, because when I checked their mail directories there was only a single copy of the email. I thought Outlook must be freaking out and downloading the same email over and over again. When I started looking into the issue this time, I noticed that I got a "no file descriptors available" when I tried to ls a directory. Then I put the two together. Dovecot keeps an index file referencing the email in the users directories. When it was unable to get a file descriptor to read this file, it ended up creating a new index file with new UID numbers for each email. In turn, this caused Outlook to think the email was new and to download it again. So at least part of the problem was the way that Dovecot handles the "no descriptor" error, its likely that it doesn't even check the errno when a file fails to open. The root cause, however, was the limited number of file descriptors available.

Interestingly enough, not having enough file descriptors didn't adversely affect Postfix. Seemingly, it simply returns a server error when receiving email that it can't write to disk.

 

Add to My Yahoo!

Add to Google

Subscribe with Bloglines

Austin Gilbert/Male/26-30. Lives in United States/Oklahoma/Tulsa/Midtown, speaks English. Spends 40% of daytime online. Uses a Fast (128k-512k) connection. And likes computer science/photography.
This is my blogchalk: United States, Oklahoma, Tulsa, Midtown, English, Austin Gilbert, Male, 26-30, computer science, photography.

Interesting problem using OpenBSD + Postfix for mass email campaigns
2007/07/22