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

Make occurrence import process atomic #62

Closed
niconoe opened this issue Nov 19, 2021 · 4 comments
Closed

Make occurrence import process atomic #62

niconoe opened this issue Nov 19, 2021 · 4 comments
Assignees
Labels

Comments

@niconoe
Copy link
Member

niconoe commented Nov 19, 2021

It would be great to have a robust mechanism to ensure the data update process happens atomically: either the Django command is successful, either the data is left unchanged (and the data update will be tried again the next day).

Possible approaches for this:

  • Use database transactions
  • Perform the data update on a copy of the database, and replace the web app's database once everything is successful

I currently favour the second option for its simplicity. Might be related/entangled with riparias/early-alert-webapp#14.

remark: even if we work on a copy of the database, don't forget to put the website in maintenance mode (#22) right before we copy the database so we are sure no changes are done (new comments added to occurrences, for example).

@niconoe niconoe self-assigned this Nov 19, 2021
@damianooldoni
Copy link
Collaborator

Or both? By using transactions towards a copy of the db?

@niconoe
Copy link
Member Author

niconoe commented Dec 1, 2021

Update: after going through the documentation, using Django's transaction support (via context manager or decorator) doesn't seem too complex/scary. So I might try this route first.

@niconoe
Copy link
Member Author

niconoe commented Dec 7, 2021

I've now implemented a simple atomic block wrapping all the database changes during data import.

On paper it looks perfect for our purpose, but we'll need to aggressively test the robustness (it looks to good to be true :) )

@niconoe
Copy link
Member Author

niconoe commented Dec 7, 2021

Now implemented, we're lacking:

@niconoe niconoe closed this as completed Dec 7, 2021
@niconoe niconoe reopened this Dec 7, 2021
@niconoe niconoe changed the title Make data import process atomic Make occurrence import process atomic Dec 14, 2021
@niconoe niconoe closed this as completed Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants