{
  "slug": "lmdb",
  "term": "LMDB",
  "aliases": [
    "Lightning Memory-Mapped Database"
  ],
  "definition": "LMDB is an embedded transactional key-value database that uses memory-mapped B+ trees, copy-on-write updates and multi-version concurrency control.",
  "note": "The original MDB design separates the application tree from a transaction-indexed free-page tree. [chu] A pinned C-API experiment kept eight 16 KiB values while varying reader lifetime; an active snapshot exhausted fixed 1 MiB and 2 MiB maps, whereas ended and reset-reader controls completed 256 overwrites. These are constructed observations, not a benchmark or failure-rate estimate. [hesela-observation]\n\nA follow-up with a stalled backup receiver exhausted both fixed maps during plain and compact copying; draining the copy restored 64 further writes. Compact output was smaller without reducing source retention. All 24 constructed cases reopened the backup and checked every value. [hesela-copy]\n\nIn 40 controlled lifecycle cases, killing a separate reader left writes at MDB_MAP_FULL until explicit reader checking cleared its abandoned entries. The tested unreaped child still had a visible PID, but cleanup restored writes at unchanged capacity. These are one-build observations, not incident rates or power-loss results. [hesela-cleanup]\n\nCustom comparison behavior must match the stored tree and be registered before data access. [api] A synthetic 0.9.33 fixture retained all 257 key/value pairs in a scan, but default-order lookups found none in its descending tree. Native/compact copies retained this dependence; normal dump/load rebuilt ascending order. No data loss or new defect was established. [hesela-comparator]\n\nAppend loading (-a) retains input order, assumes correct sorting and skips sorting/redundancy checks. It does not supply the original callback to later processes. [load-manual] [load-implementation]",
  "related": [
    "lmdb-reader-table",
    "copy-on-write",
    "snapshot-isolation",
    "b-plus-tree"
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [
    {
      "text": "Map capacity, reusable pages and live payload bytes are different quantities; these test counts are not universal thresholds.",
      "citationIds": [
        "hesela-observation"
      ]
    },
    {
      "text": "The comparator fixtures cover one pinned release and two optimization settings on one host; they exclude duplicate-key databases and writes under mismatched ordering.",
      "citationIds": [
        "api",
        "hesela-comparator"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-25",
  "citations": [
    {
      "id": "chu",
      "title": "Howard Chu. MDB: A Memory-Mapped Database and Backend for OpenLDAP. LDAPCon 2011, sections 3.2 and 4.2.",
      "url": "https://www.openldap.org/pub/hyc/mdb-paper.pdf",
      "accessed": "2026-10-16"
    },
    {
      "id": "api",
      "title": "LMDB 0.9.33 API: transaction lifetime, map capacity, reader checks and mdb_set_compare contract",
      "url": "https://github.com/LMDB/lmdb/blob/3a29a24777c82a0165de813ae696a5068b5add30/libraries/liblmdb/lmdb.h",
      "accessed": "2026-10-16"
    },
    {
      "id": "implementation",
      "title": "LMDB 0.9.33 implementation: mdb_find_oldest, mdb_page_alloc and mdb_reader_check0",
      "url": "https://github.com/LMDB/lmdb/blob/3a29a24777c82a0165de813ae696a5068b5add30/libraries/liblmdb/mdb.c",
      "accessed": "2026-10-16"
    },
    {
      "id": "hesela-observation",
      "title": "Hesela: controlled LMDB reader-lifetime experiment, complete results and limits",
      "url": "https://hesela.dev/research/lmdb-reader-lifetime.json",
      "accessed": "2026-10-16"
    },
    {
      "id": "hesela-analysis",
      "title": "LMDB readers: a stable snapshot can exhaust a fixed map",
      "url": "https://hesela.com/analyses/lmdb-readers-page-reuse-map-full/",
      "accessed": "2026-10-16"
    },
    {
      "id": "hesela-copy",
      "title": "Hesela: 24 controlled LMDB copy-backpressure observations, hashes and limits",
      "url": "https://hesela.dev/research/lmdb-copy-pressure/results.json",
      "accessed": "2026-10-20"
    },
    {
      "id": "hesela-cleanup",
      "title": "Hesela: 40 controlled LMDB reader-death and cleanup cases, method and limits",
      "url": "https://hesela.dev/research/lmdb-dead-readers/README.md",
      "accessed": "2026-10-22"
    },
    {
      "id": "load-manual",
      "title": "LMDB 0.9.33 mdb_load manual: -a ordering precondition and skipped checks",
      "url": "https://github.com/LMDB/lmdb/blob/3a29a24777c82a0165de813ae696a5068b5add30/libraries/liblmdb/mdb_load.1",
      "accessed": "2026-10-25"
    },
    {
      "id": "load-implementation",
      "title": "LMDB 0.9.33 loader implementation: greater callback and append loading",
      "url": "https://github.com/LMDB/lmdb/blob/3a29a24777c82a0165de813ae696a5068b5add30/libraries/liblmdb/mdb_load.c",
      "accessed": "2026-10-25"
    },
    {
      "id": "hesela-comparator",
      "title": "Hesela: LMDB comparator-contract fixtures, 120 retained observations and reproducible inputs",
      "url": "https://hesela.dev/research/lmdb-comparator-contract/README.md",
      "accessed": "2026-10-25"
    }
  ]
}
