Cyrus IMAP log and cache settings

This is to address the case where Cyrus IMAP runs out of log memory. Documentation on how to do deal with this is scattered around on a number of web pages, so I thought I’d consolidate things in one place.

/var/log/maillog shows the following messages:

DBERROR db4: Logging region out of memory; you may need to increase its size

at first intermittently, and then filling the log after a day or two. At this point, the mail server basically stops working, as Sendmail’s LMTP delivery process cannot communicate with Cyrus.

The solution is to increase the memory available for the Berkeley DB logging region. While doing this, we might as well increase Cyrus’s caching region, as per the Cyrus performance FAQ:

Create a DB_CONFIG file along the lines of:

# cat /var/lib/imap/db/DB_CONFIG
set_cachesize 0 2097152 1
set_lg_regionmax 1048576

This sets the cachesize to 2MB in 1 segment (the weird syntax is described in the Berkeley DB docs), and sets the log region to 1MB. The compiled-in defaults for a Fedora system appears to be 648K and 96KB, respectively.

After the file is in place, stop cyrus, run “db_recover -h /var/lib/imap/db” and start cyrus as per this Cyrus discussion.

So, to get cache and log mem stats, we run:

# db_stat -m -h /var/lib/imap/db


# db_stat -l -h /var/lib/imap/db

to verify that the settings are in effect.

Note that the db_stat and db_recover utilities are part of the db4-utils package. The path to the Cyrus BDB files (/var/lib/imap/db) is also the Fedora default, and may vary on different systems.

3 Responses to “Cyrus IMAP log and cache settings”

  1. pagalmes Says:

    Thanks, this was a valuable info. It helped me to solve this issue.

  2. rafo Says:

    thanks mate… it seems to work.. very helpfull :)
    I’ll translate it to spanish. :)

  3. zeek Says:

    The docs for Berkeley DB (as mentioned and linked above) have changed. The exact link to the db_stat doc is this:

    For the DB_CONFIG parameters: