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

✨ Reduce downtime of make refresh by swapping the database #3747

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Marigold
Copy link
Contributor

@Marigold Marigold commented Jun 26, 2024

Running make refresh induces downtime of about ~2 minutes. This is annoying when refreshing staging servers. The idea of this PR is to create a _temp database, load it and then swap with the original. Unfortunately, there's no RENAME DATABASE command in MySQL and we have to rename it table by table (and recreate views).

See slack

Other potential solutions:

  • switch to PostgreSQL
  • how about spinning up another server in a different data directory, loading into that, then shutting down the first mysql server and removing it's data directory and starting the second one?
  • The more longterm option would be we give all tables uuids and timestamps where they are missing and then change the refresh code to upsert missing rows and delete obsolete ones

Note that owid user on staging cannot create a database. We have to change its privileges in ops to

mysql> GRANT ALL PRIVILEGES ON *.* TO 'owid'@'%';
mysql> FLUSH PRIVILEGES;

@Marigold Marigold marked this pull request as draft June 26, 2024 09:42
@owidbot
Copy link
Contributor

owidbot commented Jun 26, 2024

Quick links (staging server):

Site Admin Wizard

Login: ssh owid@staging-site-refresh-swap

SVG tester:

Number of differences (default views): 1264 (f285de) ❌
Number of differences (all views): 531 (b8e7fe) ❌

Edited: 2024-06-26 09:51:44 UTC
Execution time: 1.12 seconds

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

Successfully merging this pull request may close these issues.

None yet

2 participants