What problem does it solve?
Erigon's MDBX chaindata database accumulates reclaimable pages over time, causing mdbx.dat to grow far beyond its useful data size and potentially triggering MDBX_MAP_FULL errors. This Skill compacts the database by copying it without garbage-collected pages, producing a smaller on-disk file.
Core Features & Use Cases
- Database Compaction: Copies
<datadir>/chaindata with mdbx_copy into a compacted mdbx.dat, excluding reclaimable pages.
- Safety Validation: Verifies the database file exists, checks that free disk space exceeds the current mdbx.dat size, and requires Erigon and rpcdaemon to be stopped before proceeding.
- Optional Diagnosis: Runs mdbx_stat -ef to show the Reclaimable percentage so you can decide whether compaction is worthwhile.
- Use Case: Your archive node's mdbx.dat has grown to hundreds of gigabytes and mdbx_stat shows 40% reclaimable space. Use this Skill to build mdbx_copy, compact the database in the background, swap in the compacted file, and verify the new size before restarting Erigon.
Quick Start
Compact the MDBX database in my Erigon datadir at /var/lib/erigon to reclaim free space and shrink mdbx.dat.