cryptosharks131 / lndg

Lite GUI web interface to analyze lnd data and leverage the backend database for automation tools around rebalancing and other basic maintenance tasks.
MIT License
231 stars 47 forks source link

[Data] : Error inserting closure: UNIQUE constraint failed: gui_closures.funding_txid, gui_closures.funding_index #364

Closed microlancer closed 8 months ago

microlancer commented 10 months ago

Hello,

I noticed my data on the LNDg dashboard seemed a bit stale, so I checked the logs and saw this:

Sat Jan 13 00:16:52 2024 : [Data] : Starting data execution...
Sat Jan 13 00:16:55 2024 : [Data] : Updating forwards, have 156690 
Sat Jan 13 00:16:55 2024 : [Data] : Added 0 new forwards to DB... 
Sat Jan 13 00:16:57 2024 : [Data] : Error inserting closure: UNIQUE constraint failed: gui_closures.funding_txid, gui_closures.funding_index
Sat Jan 13 00:16:57 2024 : [Data] : Data execution completed...sleeping for 20 seconds
Sat Jan 13 00:17:00 2024 : [Rebalancer] : Queue manager is starting...
Sat Jan 13 00:17:00 2024 : [Rebalancer] : Queue currently has 0 items...
Sat Jan 13 00:17:00 2024 : [Rebalancer] : There are currently 0 tasks in progress...
Sat Jan 13 00:17:00 2024 : [Rebalancer] : Queue manager is checking for more work...
Sat Jan 13 00:17:00 2024 : [Rebalancer] : Queue is still empty, stoping the rebalancer...
Sat Jan 13 00:17:00 2024 : [Rebalancer] : Queue manager has shut down...
Sat Jan 13 00:17:03 2024 : [Rebalancer] : Manager and workers have stopped...
Sat Jan 13 00:17:03 2024 : [Rebalancer] : Rebalancer successfully exited...sleeping for 20 seconds
Sat Jan 13 00:17:17 2024 : [Data] : Starting data execution...
Sat Jan 13 00:17:19 2024 : [Data] : Updating forwards, have 156690 
Sat Jan 13 00:17:19 2024 : [Data] : Added 0 new forwards to DB... 
Sat Jan 13 00:17:21 2024 : [Data] : Error inserting closure: UNIQUE constraint failed: gui_closures.funding_txid, gui_closures.funding_index
Sat Jan 13 00:17:21 2024 : [Data] : Data execution completed...sleeping for 20 seconds

Is there any reason I'm getting this UNIQUE constraint failed? Any way to resolve it?

Running v1.8.0

Thanks!

cryptosharks131 commented 10 months ago

In this case, the duplicates should be removed and lndg will try to reinsert the row on the next run but other data fields should still be able to process their data without issue.

microlancer commented 10 months ago

How can I remove the duplicates?

cryptosharks131 commented 10 months ago

This happens in the code already after the error, it tries to resolve the issue by deleting the duplicate record. https://github.com/cryptosharks131/lndg/blob/master/jobs.py#L450-L451

You could also check lncli closedchannels to see if the source list has any duplicates.

If you would like to clear the closures table completely and let lndg rebuild the list, you can go to this page and clear it manually: /reset