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.
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.
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.
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.
Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.
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.
| Symptom | Possible explanation |
|---|---|
| lmdb.MapFullError: mdb_put: MDB_MAP_FULL: Environment mapsize limit reached | The 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 capacity | The 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
- 1Ensure any failed write transaction exits cleanly before resizing the environment.
- 2Pass map_size=100 * 1024**3 (or your target ceiling) into lmdb.open() when creating or appending datasets.
- 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.
Searchable error signature
lmdb.MapFullError: mdb_put: MDB_MAP_FULL: Environment mapsize limit reachedUse 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 logsNo 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
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 / Stack | Recommendation | Notes |
|---|---|---|
| Dataset creation on 64-bit OS | Set map_size to expected max + 50% | On ext4/xfs/tmpfs, sparse data.mdb only consumes written blocks. |
| Dynamic resize recovery | Call env.set_mapsize after closing txns | Calling set_mapsize while a transaction is open raises an error. |
With the fix vs without the fix
| Dimension | With the fix | Without the fix |
|---|---|---|
| Pre-allocation choice | Explicit sparse map_size in GiB/TiB range on 64-bit hosts | Relying on Python lmdb default 10 MiB map_size |
| Transaction batching | Commit periodically every N records | Holding 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.open(default 10 MiB) -> writes exceed limit -> MDB_MAP_FULL -> open with 64-bit sparse map_size + commit chunks
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 extensionFrequently asked questions
Questions engineers and on-call staff commonly ask about this failure.
Does setting map_size=1TB consume 1TB of disk space immediately?
Note on macOS APFS/HFS+ and Windows NTFS?
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.
Related Infrastructure errors
Dual ISP BGP Route Withdrawal Causing Complete GPU Cloud Region Outage
Infrastructure · critical
Routine UPS Maintenance Triggering Cascading Power and Cooling Failure Across GPU Cloud Region
Infrastructure · critical
Remediation Storm Prevention via Circuit Breaker Pattern in AutoClusters
Infrastructure · high
Network Storage Volume Causing Process Hangs on H100 GPU Nodes
Infrastructure · high