Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot restart lightningd db since had to do fsck of hdd #4200

Closed
d4amenace opened this issue Nov 12, 2020 · 12 comments
Closed

Cannot restart lightningd db since had to do fsck of hdd #4200

d4amenace opened this issue Nov 12, 2020 · 12 comments
Labels
state::fixed These issues should have been addressed. Pending confirmation by OP, will close soon otherwise

Comments

@d4amenace
Copy link

I recently had to run an fsck and fix damaged sectors of my drive. Since I did this (and it was the only way to get my ubuntu running again), I am getting the following error message upon running lightningd:

Default-string:~$ lightningd
2020-11-12T23:09:10.885Z INFO database: Creating database
Error executing statement: wallet/db.c:1023: CREATE TABLE version (version INTEGER): database disk image is malformed

What are my options?

@ZmnSCPxj
Copy link
Contributor

ZmnSCPxj commented Nov 13, 2020

Unfortunately, if you do not have a continuous backup system like PostgreSQL cluster or the @cdecker backup plugin or ldadm/btrfs/ZFS RAID-1, you have no options. Sorry.

If you have an old backup of the database file, you can risk replacing the database with the old one, and if your peers are nice, they will close channels on you with the latest state (if they are not nice, they can steal your channels, but that is probably better than not having any chance at all of getting any of your funds back). Hopefully your peers support option_static_remotekeyoption_dataloss_protect -- if not, you will lose your channel funds (but the chance of getting some of your funds is better than losing all of them IMO).

Unfortunately due to the offchain nature of Lightning, there is nobody else who has a copy of your financial data (unlike the onchain case where every archival fullnode has a copy of every user financial data).

@d4amenace
Copy link
Author

Dammit. Are LVM snapshots any good to avoid this? Or rdiff-backup?

@ZmnSCPxj
Copy link
Contributor

Not sure. Can you recover the uncorrupted db file in an LVM snapshot?

Assuming "rdiff-backup" is similar to a process doing "rsync" regularly, you would strongly prefer to use something like the backup plugin or a PostgreSQL cluster. Stale backups are dangerous and could lose your channel funds, but then not having any backups is a definite complete and total loss of all your channel funds (whereas if your channeled peers have option_dataloss_protect then a stale backup will recover your funds, but if you have channels without option_dataloss_protect then a stale backup will definitely lose your in-channel funds with them), so it might be better than nothing.

In any case, if you have backups, you should strongly prefer the continuous backups (PostgreSQL cluster, backup plugin on an NFS mount) rather than snapshot backups, as snapshot backups can lose your money (but no backups definitely will).

@d4amenace
Copy link
Author

PostgreSQL cluster, backup plugin on an NFS moun

Do you think you could point me in the right directions to find out more about these solutions. Links or web pages?

@ZmnSCPxj
Copy link
Contributor

It seems we do not have single coherent document for this yet, sorry. Certainly could be something we add to doc/ directory.

@jsarenik
Copy link
Contributor

Related to #4181 ?

@d4amenace
Copy link
Author

d4amenace commented Nov 16, 2020

If PostgreSQL is superior to SQLite, then why isn't it standard in the software? Curious

@ZmnSCPxj
Copy link
Contributor

PostgreSQL requires a lot more setup especially if you want to replicate the data across multiple machines. And C-Lightning started out using SQLITE3 and without PostgreSQL support, so for back-compatibility, SQLITE3 support is default and PostgreSQL support is not compiled in by default (otherwise people using SQLITE3 databases from old C-Lightning versions would be forced to install the much larger PostgreSQL packages, whereas SQLITE3 is a fairly small library). Probably @cdecker can give more perspective on PostgreSQL use (possibly he is the only core developer of C-Lightning who has a PostgreSQL setup even, so...)

Also, nothing in the protocol requires any particular database, it only mandates when particular data is stored in permanent storage relative to your communications with peers, but that is just me being pedantic, you probably mean just "C-Lightning software" and not "protocol".

@rustyrussell
Copy link
Contributor

If you can get an old copy of the db, it's worth a try: you might lose funds but usually not because peers are honest.

However, generally we can't recover from corrupted storage very well :(

@d4amenace
Copy link
Author

you probably mean just "C-Lightning software" and not "protocol".

Exactly.

@d4amenace
Copy link
Author

I am actually aware of how my db got corrupted. I can avoid it on my other servers. I am rolling out a payment system that uses C-lightning nodes and I am just looking for a backup solution for professional peace of mind.

@cdecker
Copy link
Member

cdecker commented Dec 2, 2021

I think this issue has been addressed by the backup documentation (thanks @ZmnSCPxj ) so I think we can close this for now?

@cdecker cdecker added the state::fixed These issues should have been addressed. Pending confirmation by OP, will close soon otherwise label Dec 2, 2021
@cdecker cdecker closed this as completed Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state::fixed These issues should have been addressed. Pending confirmation by OP, will close soon otherwise
Projects
None yet
Development

No branches or pull requests

5 participants