Skip to content

LMDB lmdb.MapFullError: MDB_MAP_FULL Fix

Resolve lmdb.MapFullError: mdb_put: MDB_MAP_FULL: Environment mapsize limit reached in dataset builders. Resize map_size cleanly without corruption.

Quick answer

lmdb.MapFullError: mdb_put: MDB_MAP_FULL happens when an LMDB database outgrows the virtual map_size configured at lmdb.open(). Abort the active write transaction, re-open the environment with a larger map_size (set comfortably above peak dataset size on 64-bit Linux), and resume or commit writes.

Symptom
lmdb.MapFullError: mdb_put: MDB_MAP_FULL: Environment mapsize limit reached
Root cause
The active write transaction ran out of pages inside the configured LMDB map_size limit, which defaults to 10485760 bytes (10 MiB) unless overridden.
Recommended fix
Set an explicit large map_size in lmdb.open(path, map_size=...) on 64-bit Linux (for example 100 * 1024**3 for 100 GiB); LMDB allocates disk pages lazily via sparse files, not upfront.
How Denpex helps
Denpex investigates LMDB lmdb.MapFullError: MDB_MAP_FULL Fix using the evidence you provide or your connected workload collects. Earlier rank, host or application evidence is needed to distinguish an initiating failure from a downstream report.
Infrastructure#lmdb#mdb-map-full#datasets#preprocessing#storage

What this failure is

An LMDB storage exception raised when a write transaction exceeds the pre-allocated memory-map ceiling (map_size) of the LMDB environment.

Live diagnosis, no signup

Is this what broke your run? Paste your log.

You're reading about LMDB lmdb.MapFullError: MDB_MAP_FULL Fix. Paste your own traceback and relevant evidence for an investigation of your workload, with a next action or a specific missing fact. A reference entry does not establish your cause. No account or card for the free diagnosis. Review data handling before submitting sensitive logs.

Before uploading, review cloud data handling and local options.

training_logs.txt
No log to hand? Try one:

Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.

3 free cloud diagnoses per day

Why it happens (the mechanism)

LMDB maps its data file into virtual address space with a fixed maximum map_size at open time (the default Python lmdb map_size is only 10 MiB). On 64-bit Linux, virtual address space is sparse on disk, so small defaults or underestimated dataset builds hit MDB_MAP_FULL mid-write.

What you'll observe

  • Dataset preprocessing scripts crash partway through writing image/feature shards with lmdb.MapFullError.
  • Interrupted multi-hour preprocessing runs fail to store remaining samples unless restarted or caught with a map resize.

Common symptoms and what they mean

Check possible explanations against the incident evidence. A matching symptom alone does not establish its cause.

SymptomPossible explanation
lmdb.MapFullError: mdb_put: MDB_MAP_FULL: Environment mapsize limit reachedThe active write transaction ran out of pages inside the configured LMDB map_size limit, which defaults to 10485760 bytes (10 MiB) unless overridden.
Preprocessor aborts at a deterministic record count matching map_size capacityThe active write transaction ran out of pages inside the configured LMDB map_size limit, which defaults to 10485760 bytes (10 MiB) unless overridden.

Which systems are affected

  • Python lmdb dataset builders (PyTorch vision datasets, TensorRT calibration caches, feature stores)
  • 64-bit Linux and 32-bit environments writing datasets larger than the default 10 MiB map_size

How to confirm this is the problem

Use this checklist to test the hypothesis against a small reproduction. No single line proves the root cause, so preserve the preceding events and compare one variable at a time.

  • ✓Inspect env.info()['map_size'] and compare total bytes serialized against map_size.
  • ✓Run a full preprocessing pass and inspect actual disk usage with ls -lsh data.mdb.

Root cause

  • The active write transaction ran out of pages inside the configured LMDB map_size limit, which defaults to 10485760 bytes (10 MiB) unless overridden.

The fix and how to prevent it

How to fix it

  • Set an explicit large map_size in lmdb.open(path, map_size=...) on 64-bit Linux (for example 100 * 1024**3 for 100 GiB); LMDB allocates disk pages lazily via sparse files, not upfront.
  • Ensure your script catches lmdb.MapFullError outside an aborted write transaction, doubles env.set_mapsize(new_size) only after no active transactions remain, and retries the record.
  • Check du -sh and stat on data.mdb so you distinguish sparse virtual map_size from actual consumed filesystem blocks and quota limits.

Step-by-step remediation

  1. 1Ensure any failed write transaction exits cleanly before resizing the environment.
  2. 2Pass map_size=100 * 1024**3 (or your target ceiling) into lmdb.open() when creating or appending datasets.
  3. 3Commit every 1,000 to 10,000 records to limit dirty memory pages and allow resumable writes.

How to prevent it

  • Configure map_size based on estimated raw dataset size multiplied by a 1.5x B-tree overhead margin on 64-bit systems.
  • Avoid overwriting existing records repeatedly inside single huge uncommitted transactions, which retains old MVCC pages until commit.

Save this diagnosis and catch the next crash automatically

All root cause, fix, and prevention steps above are free to read. Create a free account with any email or GitHub to keep your saved diagnosis history across the encyclopedia and run cloud checks, or use a work email below for the 30-day Team evaluation. No card required.

Or start a 30-day free Team trial (work email)

Verified work email unlocks all 14 fleet diagnostic tools, Slack alerts, and team history for 30 days. No card and no automatic charge.

Use your company email, for example alex@yourcompany.com.

Who qualifies?

Company email domains activate the free 30-day Team evaluation (up to 50 diagnoses a day) after an email and domain check, whatever mail provider you use. If we cannot verify your domain automatically, support reviews it: write to support@denpex.com. Free local diagnosis in the editor extension needs no account.

Using a personal email (Gmail, Outlook, Naver, QQ) or solo cluster? Create a free $0 account (no work email required) to save 7-day history and unlock AI fallback, or send a cluster crash log for a live walkthrough.
Already have an account? Sign in

Searchable error signature

search key
lmdb.MapFullError: mdb_put: MDB_MAP_FULL: Environment mapsize limit reached

Use this text as a lookup key in logs and upstream issue trackers. It is not presented as a captured customer log. Confirm the cause from your own preceding events, versions, configuration and the cited references.

Diagnose your own log automatically

The root cause and fix steps above stay free. Create a free account to analyze full job logs, attribute the first failed rank, and keep saved incident history.

Sign up free. Analyze your cluster logs

No credit card. Daily allowance follows verified trust tier. Instant access.

Why the recommended fix works

LMDB uses virtual memory mapping with sparse file backing on Linux, so declaring a generous 64-bit map_size avoids B-tree page exhaustion without pre-consuming real SSD space.

Code examples

snippet
import lmdb

# 64-bit Linux sparse map_size ceiling (100 GiB max, real disk grows lazily)
env = lmdb.open("/data/train.lmdb", map_size=100 * 1024 ** 3)
with env.begin(write=True) as txn:
    txn.put(b"sample_0001", payload_bytes)

This snippet illustrates the entry-specific check. Verify the installed versions, permissions, target and workload context before using it. A command or API example is not proof of recovery.

Best practices by model family

Model / StackRecommendationNotes
Dataset creation on 64-bit OSSet map_size to expected max + 50%On ext4/xfs/tmpfs, sparse data.mdb only consumes written blocks.
Dynamic resize recoveryCall env.set_mapsize after closing txnsCalling set_mapsize while a transaction is open raises an error.

With the fix vs without the fix

DimensionWith the fixWithout the fix
Pre-allocation choiceExplicit sparse map_size in GiB/TiB range on 64-bit hostsRelying on Python lmdb default 10 MiB map_size
Transaction batchingCommit periodically every N recordsHolding one multi-hour giant uncommitted write transaction

Diagnostic note

“Grounded in LMDB mdb_env_set_mapsize documentation and Python lmdb sparse file semantics on 64-bit filesystems.”

Visual fingerprint

LMDB map_size sizing flow
lmdb.open(default 10 MiB) -> writes exceed limit -> MDB_MAP_FULL -> open with 64-bit sparse map_size + commit chunks
Virtual map_size limits address space ceiling, while sparse files grow on disk only as pages are committed.

Diagnose this failure in VS Code

Select the traceback or open the failed terminal, then run Denpex locally to inspect matched failure patterns, supporting evidence and next checks without uploading the log. Verify recommendations against your workload before changing production.

Install the free VS Code extension

Frequently asked questions

Questions engineers and on-call staff commonly ask about this failure.

Does setting map_size=1TB consume 1TB of disk space immediately?
No, on Linux filesystems like ext4 and XFS, LMDB creates a sparse file whose apparent size matches map_size while actual allocated disk blocks only equal written pages.
Note on macOS APFS/HFS+ and Windows NTFS?
Unlike Linux sparse files, some macOS/Windows filesystem calls allocate real disk blocks up to map_size, so size map_size closely to expected dataset size on those OSes.

Don't just read the fix, diagnose your run

The encyclopedia explains documented failure patterns. Denpex investigates your logs, configuration and stack, shows the supporting evidence, and asks for missing details when needed.