DISCLAIMER: This guide is for advanced node operators, NOT new nodes or small personal nodes. Is more for those nodes that are doing a lot of routing every day, closing / opening a lot of channels, merchants with a lot of generated invoices, failed invoices, with a lot of traffic generated.
So if you are just a noob starting a fresh node now, IGNORE this guide.
To explain a bit what is about. The
channel.db file located in
/umbrel/lnd/data/graph/mainnet/ in time it grows bigger and bigger until is quite hard to manage it and file corruption can be most probable to a larger file than a smaller one. Also this file is loaded in memory, so for smaller it is, less memory in use will be. It affect also the response time of your node for routing payments.
So, in conclusion it is quite important to keep this file as lower is possible.
Why I did this test? I was reading this post on Github about the aspect of dealing with large db file and slowliness of a node.
Now I am glad that I did it and I would like to share it with you. Those that are seeing lately that you node is acting weird and is slow, worth doing this. It is safe, works easy and can save you from future trouble.
- Stop your Umbrel node - SSH into your node and run
cd umbrel sudo ./scripts/stop
- Edit lnd.conf file
sudo nano ~/umbrel/lnd/lnd.conf
Add the following line and section at the end:
[bolt] db.bolt.auto-compact=true db.bolt.auto-compact-min-age=0
In the section [Application Options] add the following lines too, for a better cleanup:
# Mark unpayable, unpaid invoices as deleted gc-canceled-invoices-on-startup=1 gc-canceled-invoices-on-the-fly=1 # Avoid historical graph data sync ignore-historical-gossip-filters=1 # Avoid slow startup time sync-freelist=1 # Avoid high startup overhead stagger-initial-reconnect=1 # Avoid auto force close channels payments-expiration-grace-period=30m
- Check the size of actual channel.db file:
cd ./umbrel/lnd/data/graph/mainnet/ sudo du -ah
It will show you the files in that folder and size in MB of each. You can use the same command after the compacting process to see the difference. Also in lnd logs you can see it mentioned of how much was reduced in size.
Start your node normally:
WAIT! In this moment you need patience, a lot of patience. Don’t do anything stupid, do not restart the node or unplug it. It is normal that is taking more time to start.
What is doing? First step, is catching up the bitcoin blocks, could takes 5-15min, then is making a copy of channel.db file and start compacting it.
Check the bitcoin status with (login SSH into your node):
cd umbrel docker-compose logs bitcoin docker-compose logs lnd
See when the compaction is finished you will see a line where it says the initial size and new size of the file.
In my case, from 2GB file, went to 500MB in 2h:30m waiting.
DONE! Now your node is ready and should be more faster in response and routing.