Closed SimonVrouwe closed 5 years ago
I've seen this before when the DB is not initialized correctly after opening it: you need to execute the following statement to enable foreign keys:
PRAGMA foreign_keys = ON;
This is needed since we rely on foreign key relationships to cascade deletions from one table to dependent ones. In this specific case it is likely that the blocks
entry for block 591848 was deleted, but did not result in the deletion cascading the deletion to the entries in utxoset
which would have avoided the conflict. I'm pretty sure that other constraints will also have been violated so please grab a new copy of the DB instead of trying to recover.
I added some comments to this end on the dbbackup PR here https://github.com/lightningd/plugins/pull/40.
I think that plugin is still under development and the issues should be reported there, so closing this :wink:
you need to execute the following statement to enable foreign keys:
PRAGMA foreign_keys = ON;
How could the backup have missed that one? It should have nicely been reported to the plugin https://github.com/ElementsProject/lightning/blob/3ef5160fa7cc8eadb9dc9cf5443e02ebec79ed8e/wallet/db.c#L673-L674
Might be an issue with the way the plugin buffers statements before it is inited?
Found it, creating the initial backup from a copy of the original does not copy the PRAGMA ! I guess a PRAGMA is more a property of the connection.
@cdecker Thanks for the push in the right direction.
Was running version
v0.7.2rc2-modded
(no idea why it shows modded) together with the dbbackup.edit: maybe plugin issues don't belong here, but maybe it is relevant
There was a chain reorg 26 aug, which triggered a write failure in the plugin when writing to backup:
and crashed the node, see full crash log below. Looks similar to #1280, or maybe #2968?
What I found so far using sqlite3
.dbinfo
on original db and backup:software version: 3016002
software version: 3022000
The plugin runs on python3 (3.6.4 Anaconda Inc.) and its
sqlite3
module shows indeed v3.22.0.I forgot to make a copy of the original right after the crash, but I do have the backup, which correctly failed the compare-check when restarting the node.