Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lmtp ratelimit #5032

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Lmtp ratelimit #5032

wants to merge 3 commits into from

Conversation

brong
Copy link
Member

@brong brong commented Sep 12, 2024

We're running into issues in Fastmail production where a single mailbox locked up for a crazy amount of time can cause starvation by having hundreds of lmtp processes waiting on locks.

We could test for locks, but it's OK to have a few waiting - we should just tell the rest to try again later. This re-uses the
proc_checklimit in lmtpd to check the limits for each userid before trying to lock their conversations.db, and returns a useful 451 code to the sender saying that there are too many connections for this user.

We'll probably set something like a 10 process limit for our servers, which allows for all the MXes to send one and a few spares still open.

@brong
Copy link
Member Author

brong commented Sep 12, 2024

Sadly there's no test cases for maxlogins in general, and it's particularly hard to test for this case, because it only limits while the lmtp delivery itself is happening, so you'd need to hold a lock on the user's conversationsdb!

Copy link
Member

@rsto rsto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved under the condition that we won't merge until further testing shows this is sane. Tagged as Do-Not-Merge.

lib/proc.c Show resolved Hide resolved
@brong
Copy link
Member Author

brong commented Sep 12, 2024

I rebased and merged in some patch code for the return code - I had originally had it coming from lib/proc.c but we don't have IMAP errors there, and when I removed that bit I forgot to add it to the caller. That's now fixed :)

imap/lmtpd.c Outdated Show resolved Hide resolved
This means that somebody with 5 imap connections won't be locked out from
pop, but more importantly won't block lmtp delivery once we add that as
a limitable service.
The sends a sensible 4xx response back to the user, with an error
message saying which limit was hit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants