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

Fix Liquid database migration #4976

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

natsoni
Copy link
Contributor

@natsoni natsoni commented Apr 16, 2024

This PR fixes the broken database migration scheme 75 by adding a network check in the migration before truncating bitcoin specific tables.

@wiz
Copy link
Member

wiz commented Apr 16, 2024

why didn't this issue reproduce in production?

@natsoni
Copy link
Contributor Author

natsoni commented Apr 16, 2024

why didn't this issue reproduce in production?

It looks like database migration to version 75 was modified on April 4th, about 2 weeks after it got added to master on March 13th. These lines were added:

await this.$executeQuery('TRUNCATE hashrates');
await this.$executeQuery('TRUNCATE difficulty_adjustments');
await this.$executeQuery(`UPDATE state SET string = NULL WHERE name = 'pools_json_sha'`);

Maybe prod got upgraded to version 75 before the migration being updated with the above changes that broke Liquid?

@wiz
Copy link
Member

wiz commented Apr 16, 2024

Yeah it might be a better idea to simply revert that commit and add a new migration for the truncate

@wiz
Copy link
Member

wiz commented Apr 16, 2024

Also there shouldn't be more than one SQL query per migration in case it fails

Copy link
Member

@wiz wiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert the breaking commit and instead add a few new migrations that do the same thing, with the correct network check if necessary

@natsoni
Copy link
Contributor Author

natsoni commented Apr 16, 2024

IIRC the breaking commit was added to fix a production bug with the hashrates table that is now fixed. @nymkappa can you confirm? If yes, only reverting the commit should be enough?

Copy link
Member

@softsimon softsimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested ACK @ [ea1e269]

I can confirm my current Liquid database wasn't affected by this bug. I had to try a clean database, and it reproduces.

@wiz
Copy link
Member

wiz commented Apr 16, 2024

TRUNCATE'ing the hashrates and difficulty adjustments is just a re-index, just move those to their own new migrations and it will be fine

@natsoni natsoni force-pushed the natsoni/fix-liquid-db-migration branch from ea1e269 to 1c55eef Compare April 16, 2024 20:43
@natsoni natsoni requested a review from wiz April 18, 2024 07:27
Copy link
Member

@wiz wiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@wiz
Copy link
Member

wiz commented Apr 18, 2024

Will merge after manually bumping prod servers to 81 to avoid the re-indexing downtime

@wiz wiz added this to the v3.0 milestone May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants