Skip to content

Use ATOMIC_REQUESTS=True to wrap every django request in a database transaction #1400

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

Merged
merged 1 commit into from
Jul 6, 2015

Conversation

gregmuellegger
Copy link
Contributor

I think it is a good practice to wrap every request in a transaction. I think we already have lots of places in the codebase that do not explicitly run in a transaction which makes it possible that a requests aborts in the middle (for example in case of an exception) and leaves the DB in an inconsistent state as we might have already processed some, but not all incoming data.

The django documentation states that this might impact performance a bit depending on the used database.

So I'm not sure if that really is the perfect option for readthedocs, but I think we make everything a little more predictable that way :)

@ericholscher
Copy link
Member

This seems like a good idea. We can monitor the site to see if contention arises in the DB from this, but generally our DB queries are fine, with only the Build tables being slow, and they are only updated via the API and CLI, so shouldn't be too long lived.

ericholscher added a commit that referenced this pull request Jul 6, 2015
Use ATOMIC_REQUESTS=True to wrap every django request in a database transaction
@ericholscher ericholscher merged commit 2e1de68 into master Jul 6, 2015
@gregmuellegger gregmuellegger deleted the use-atomic-requests branch August 3, 2015 13:57
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.

2 participants