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: attempt db rename during reset #1801

Merged
merged 2 commits into from
Dec 1, 2023
Merged

Fix: attempt db rename during reset #1801

merged 2 commits into from
Dec 1, 2023

Conversation

thekaveman
Copy link
Member

Updates the bin/init.sh script to first rename the existing database file before deleting, in the case of a DB reset.

This is a follow-up to #1775 -- with the Sqlite file stored in an Azure SMB fileshare, when we rm django.db the file is only marked for deletion in Azure, which could take a few minutes.

In the meantime, python manage.py migrate is attempting to recreate/write to the file that may still exist (and locked for deletion). We're seeing an increase in healthcheck failures as the app restarts and finally clears the file lock:

2023-12-01T17:35:15.514065207Z + bin/init.sh
2023-12-01T17:35:15.554876476Z + [[ true = true ]]
2023-12-01T17:35:15.555739988Z + DB_DIR=./data
2023-12-01T17:35:15.555886290Z + DB_FILE=./data/django.db
2023-12-01T17:35:15.556020892Z + rm -f ./data/django.db
2023-12-01T17:35:15.604529968Z + python manage.py migrate
...
2023-12-01T17:35:20.778732650Z django.db.utils.OperationalError: unable to open database file
...
2023-12-01T17:35:20.847969505Z Waiting up to 2 seconds
2023-12-01T17:35:20.847989805Z Press Ctrl-C to quit
...
2023-12-01T17:38:08.788212280Z + bin/init.sh
2023-12-01T17:38:08.895594785Z + [[ true = true ]]
2023-12-01T17:38:08.895632085Z + DB_DIR=./data
2023-12-01T17:38:08.895648586Z + DB_FILE=./data/django.db
2023-12-01T17:38:08.895652986Z + rm -f ./data/django.db
2023-12-01T17:38:08.916634280Z + python manage.py migrate
...
2023-12-01T17:38:13.808992207Z Operations to perform:
2023-12-01T17:38:13.810500928Z   Apply all migrations: admin, auth, contenttypes, core, sessions
2023-12-01T17:38:13.818119733Z Running migrations:
...

trying to avoid a file lock on the existing file
after it has been marked for deletion
@thekaveman thekaveman added bug Something isn't working chore Chores and tasks for code cleanup, dev experience, admin/configuration settings, etc. infrastructure Terraform, Azure, etc. labels Dec 1, 2023
@thekaveman thekaveman added this to the Admin tool: v1 milestone Dec 1, 2023
@thekaveman thekaveman self-assigned this Dec 1, 2023
@thekaveman thekaveman requested a review from a team as a code owner December 1, 2023 17:55
@github-actions github-actions bot added the deployment-dev [auto] Changes that will trigger a deploy if merged to dev label Dec 1, 2023
Copy link

github-actions bot commented Dec 1, 2023

Coverage report

The coverage rate went from 90.87% to 90.87% ➡️
The branch rate is 85%.

None of the new lines are part of the tested code. Therefore, there is no coverage data about them.

@thekaveman thekaveman merged commit 9ac066b into dev Dec 1, 2023
10 checks passed
@thekaveman thekaveman deleted the fix/init branch December 1, 2023 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working chore Chores and tasks for code cleanup, dev experience, admin/configuration settings, etc. deployment-dev [auto] Changes that will trigger a deploy if merged to dev infrastructure Terraform, Azure, etc.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants