LMDB recovery

LMDB keeps committed data in a memory-mapped B+ tree, so application writes should stop before page damage spreads.

An LMDB environment normally contains data.mdb plus a runtime lock.mdb. Copy-on-write pages and two meta pages provide transactional consistency, but media damage, unsafe copying during writes, map-size problems, or application misuse can leave unreadable pages or inconsistent references.

Understand the symptom

Meta pages select a committed transaction root; page trees and free-page records must agree.

WHY

What is happening

A newer meta page can be damaged while an older transaction remains coherent. Recovery must evaluate page numbers, transaction IDs, branch and leaf structure, overflow pages, named databases, and the free list without committing new writes.

What you may see

Symptoms that change the recovery path.

01

MDB_INVALID or bad magic

The file header or expected LMDB layout is unreadable.

02

Page not found or corrupt

A branch, leaf, overflow, or free-page reference may be invalid.

03

Database fails after copy

Files may have been copied inconsistently while a writer was active.

04

Readers work but writes fail

Map size, locks, free pages, or filesystem state may be involved.

Protect the source

Actions that can make the situation worse.

01

Opening read-write changes pages

Use protected copies and read-only analysis first.

02

Copying lock.mdb as data misleads

It is coordination state and can be regenerated when safe.

03

Free-list damage can overwrite live pages

Do not resume writes before consistency is understood.

Do this now

Safe steps before evaluation.

01

Stop the owning application

Prevent new transactions and maintenance.

02

Snapshot the whole environment

Hash data.mdb and retain lock and configuration for context.

03

Record flags and map size

Keep MDB_NOSUBDIR, max readers, named DB, and filesystem details.

04

Preserve backups and exports

Do not overwrite older consistent copies.

NEPFOSYS process

How a data-first evaluation proceeds.

01

Meta-page review

NEPFOSYS compares transaction roots, page size, geometry, and environment context.

02

Tree traversal

Reachable branch, leaf, overflow, named database, and free-list pages are mapped from a copy.

03

Record validation

Recovered keys and values are checked against application encoding, counts, and alternate snapshots.

A clear next step

Preserve the original device before another repair or recovery attempt.

Start a case with the exact symptoms, incident timeline, prior attempts, encryption details, and the files that matter most. NEPFOSYS will route the case to the appropriate DFW intake or nationwide mail-in path.

Start with a case review

Questions, answered

What customers ask before starting.

Does lock.mdb contain my records?

No. User data is in data.mdb; lock.mdb coordinates readers and writers.

Can an older meta page help?

Sometimes, if it references a complete earlier committed transaction.

Should I run the application to test it?

Not on the original. Application startup may open the environment read-write.

DFW local · Nationwide mail-in

Protect the device. Start with the facts.

Start my recovery case