PPoossttffiixx OOppeennLLDDAAPP LLMMDDBB HHoowwttoo

-------------------------------------------------------------------------------

IInnttrroodduuccttiioonn

Postfix uses databases of various kinds to store and look up information.
Postfix databases are specified as "type:name". OpenLDAP LMDB (called "LMDB"
from here on) implements the Postfix database type "lmdb". The name of a
Postfix LMDB database is the name of the database file without the ".lmdb"
suffix.

This document describes:

  * Building Postfix with LMDB support.

  * Configuring LMDB settings.

  * Supported minimum LMDB patchlevel.

BBuuiillddiinngg PPoossttffiixx wwiitthh LLMMDDBB ssuuppppoorrtt

Postfix normally does not enable LMDB support. To build Postfix with LMDB
support, use something like:

    % make makefiles CCARGS="-DHAS_LMDB -I/usr/local/include" \
        AUXLIBS="-L/usr/local/lib -llmdb"
    % make

Solaris may need this:

    % make makefiles CCARGS="-DHAS_LMDB -I/usr/local/include" \
        AUXLIBS="-R/usr/local/lib -L/usr/local/lib -llmdb"
    % make

The exact pathnames depend on how LMDB was installed.

When building Postfix fails with:

    undefined reference to `pthread_mutexattr_destroy'
    undefined reference to `pthread_mutexattr_init'
    undefined reference to `pthread_mutex_lock'

Add the "-lpthread" library to the "make makefiles" command.

    % make makefiles .... AUXLIBS="... -lpthread"

CCoonnffiigguurriinngg LLMMDDBB sseettttiinnggss

Postfix provides one configuration parameter that controls LMDB database
behavior.

  * lmdb_map_size (default: 16777216). This setting specifies the initial LMDB
    database size limit in bytes. Each time a database becomes full, its size
    limit is doubled. The maximum size is the largest signed integer value of
    "long".

SSuuppppoorrtteedd mmiinniimmuumm LLMMDDBB ppaattcchhlleevveell

Currently, Postfix supports LMDB 0.9.11 or later. The supported minimum LMDB
patchlevel has evolved over time, as the result of deployment experience with
Postfix.

  * LMDB 0.9.11 allows Postfix daemons to log an LMDB error message, instead of
    falling out of the sky without any notification.

  * LMDB 0.9.10 closes an information leak where LMDB was writing up to 4kbyte-
    chunks of uninitialized heap memory to the database, persisting information
    that was not meant to be persisted, or sharing information that was not
    meant to be shared.

  * LMDB 0.9.8 allows Postfix to use external (fcntl()-based) locks, instead of
    having to use world-writable LMDB lock files.

  * LMDB 0.9.8 allows an application to recover from a "database full" error
    without having to close the database, by adding support to update the
    database size limit on-the-fly; and it adds support for an application to
    adopt someone elses change to the database size limit, without having to
    close the database.

  * LMDB 0.9.7 allows the postmap and postalias commands to use a bulk-mode
    transaction larger than the amount of physical memory. This is necessary
    because LMDB supports databases larger than physical memory.

