channeldb/kvdb/bolt: automated database compaction #4131
Labels
advanced
Issues suitable for very experienced developers
database
Related to the database/storage of LND
enhancement
Improvements to existing features / behaviour
v0.12
Projects
Milestone
With the way our primary database
bbolt
works, disk space is actually never reclaimed when something is deleted. Instead, page where the data is stored is eventually added to a free list, which will then be re-used when we need to update or insert some new data. As a result, the database and the free list will continue to grow until compaction is done. For those users that sync the free list (--sync-freelist
), a larger free list due to infrequent compactions will also result in longer start up time.Ideally we modify things so we either do a compaction:
The first two options seem the easiest, as we don't need to try to compact a live database. Users can do this manually as is, but we should wrap it up in a nice easy to use command so it's less error prone.
As far as the compaction logic, we can borrow the logic for
bbolt
's compaction command as is. Compaction at a high level is actually just copying over all the keys, buckets and sequence numbers into a new database. Typically a user needs to manually rename files in this process, but our automated version should do this all automatically.The one thing we'll need to be mindful of us that our automated compaction is able to survive restarts properly, and also doesn't act if there isn't enough disk space for the compacted copy.
The text was updated successfully, but these errors were encountered: