Mail: Dovecot default_vsz_limit stuck at 256M, large mailboxes fail to mmap their index cache
On mailboxes with a large index cache, Dovecot logs this when they are opened or indexed (Cloudron 10.1.5, mail 4.4.4, Dovecot 2.4.2; it already happened with 10.0.5 and Dovecot 2.3):
indexer-worker(user1@example.com): Error: Mailbox INBOX: mmap(size=200498572) failed with file /app/data/vmail/user1@example.com/mail/dovecot.index.cache: Cannot allocate memory
imap(user2@example.com): Error: Mailbox Archive: mmap(size=111789528) failed with file /app/data/vmail/user2@example.com/mail/.Archive/dovecot.index.cache: Cannot allocate memory
A third mailbox (about 170,000 mails, 48 GB) has a 313 MB dovecot.index.cache and fails the same way. Dovecot then works without the cache, and these mailboxes are slow to open.
The cause is Dovecot's per-process limit, which stays at its default:
# doveconf -h default_vsz_limit
256 M
dovecot.conf.template does not set it. Raising the mail service memory limit in the dashboard does not help: the container now has about 25 GB, and every Dovecot process is still capped at 256M. Dovecot's own sample config says so: "Most of the memory goes to mmap()ing files. You may need to increase this limit if you have huge mailboxes."
Could the mail container raise this limit, either default_vsz_limit or vsz_limit for service imap and service indexer-worker (1G for example)? It could also follow the memory limit set in the dashboard. A supported way to add a custom Dovecot setting would solve it as well.