PPoossttffiixx OOppeennLLDDAAPP LLMMDDBB HHoowwttoo

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

IInnttrroodduuccttiioonn

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.

BBuuiillddiinngg PPoossttffiixx wwiitthh LLMMDDBB ssuuppppoorrtt

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"

CCoonnffiigguurriinngg LLMMDDBB sseettttiinnggss

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".

SSuuppppoorrtteedd mmiinniimmuumm LLMMDDBB ppaattcchhlleevveell

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.

