Skip to content

Unable to update database #6700

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

Closed
hMsats opened this issue Sep 21, 2023 · 8 comments
Closed

Unable to update database #6700

hMsats opened this issue Sep 21, 2023 · 8 comments
Assignees
Labels
in diagnostic issue under diagnostic
Milestone

Comments

@hMsats
Copy link
Contributor

hMsats commented Sep 21, 2023

Issue and Steps to Reproduce

2023-09-21T06:53:21.924Z INFO    plugin-clnrest.py: Killing plugin: disabled itself: No module named 'flask'
2023-09-21T06:53:21.937Z INFO    lightningd: Updating database from version 234 to 235
2023-09-21T06:53:21.937Z **BROKEN** lightningd: query failed: wallet/wallet.c:5721: SELECT rune, last_used_nsec FROM runes
query failed: wallet/wallet.c:5721: SELECT rune, last_used_nsec FROM runes

getinfo output

Master (a0f4eb9)

@vincenzopalazzo
Copy link
Collaborator

Thanks for the bug report

Maybe this is relate to this #6696

@ddustin
Copy link
Collaborator

ddustin commented Sep 21, 2023

I believe this was caused by a migration issue from this commit: eacf0b5#diff-1abcdf1b9d822b30079d6450b790274bdfb7c7fa04baa43ad2d9bd449865d4c9R978

Meaning the alter table query
ALTER TABLE runes ADD last_used_nsec BIGINT DEFAULT NULL
was never run on your database.

Artifacts of running on bleeding edge master 😅. You probably should be able to run the command manually and get up and running but screwing with your DB is risky. Maybe shut it down and back it all up first? Caveat emptor 😬

@hMsats
Copy link
Contributor Author

hMsats commented Sep 22, 2023

@vincenzopalazzo as suggested above, executing the line: ALTER TABLE runes ADD last_used_nsec BIGINT DEFAULT NULL by hand on the database solved the issue. So for some (strange) reason it was never executed during the database update.

@hMsats
Copy link
Contributor Author

hMsats commented Sep 22, 2023

@vincenzopalazzo I think I found the reason for this issue in the source code. See my pull request.

@ShahanaFarooqui
Copy link
Collaborator

The error message and the PR (#6713) do not seem to be related. IMHO, @ddustin suggestion solved your issue and then you found another issue which you resolved with the PR.

No further action is required, so closing this issue now.

@ddustin
Copy link
Collaborator

ddustin commented Sep 22, 2023

@ShahanaFarooqui the issue was caused because a database command was added second-to-last instead of last in the dbmigration array here: eacf0b5#diff-1abcdf1b9d822b30079d6450b790274bdfb7c7fa04baa43ad2d9bd449865d4c9R978

The result of this is people updating from before this commit to after will never get the ALTER TABLE runes command and instead will have migrate_runes_idfix run a second time.

@ShahanaFarooqui
Copy link
Collaborator

@ShahanaFarooqui the issue was caused because a database command was added second-to-last instead of last in the dbmigration array here: eacf0b5#diff-1abcdf1b9d822b30079d6450b790274bdfb7c7fa04baa43ad2d9bd449865d4c9R978

The result of this is people updating from before this commit to after will never get the ALTER TABLE runes command and instead will have migrate_runes_idfix run a second time.

Ohh I remember now. It happened because when I rebased the PR, it merged it in the wrong direction. And fixed that in further commits :)

@vincenzopalazzo
Copy link
Collaborator

What is the solution here?

as suggested above, executing the line: ALTER TABLE runes ADD last_used_nsec BIGINT DEFAULT NULL by hand on the database solved the issue.

I really hope it is not this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in diagnostic issue under diagnostic
Projects
None yet
Development

No branches or pull requests

4 participants