-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Project: Deleting a project cascades computations that time out #10040
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
Comments
I think we probably just want to delete things in a celery task, and not in process. To do that properly we need a bit more thought on UX, but in general even a 1-2 minute delete is better than a 502 that doesn't work :) |
@ericholscher I like that the action is atomic and gives direct feedback. I don't think we need a celery task for this, we just need to not hit the database once for every page visit that has been logged in analytics. We can probably wrap a db transaction around this. As for celery tasks, the deletion of content and search indexes takes place async. Unfortunately, they are added BEFORE deleting the project, so the atomicity is a bit so-so.. would be best to delete this after the deletion of the project has gone well. The |
I'd propose to explore this idea:
I'm assuming that
If the query takes more than 30s, we will need to somehow exclude it from our general limitation.
This is not 100% true. Django won't call
(from https://docs.djangoproject.com/en/4.1/ref/models/fields/#django.db.models.CASCADE) |
I'm +1 with this idea, just manually call |
@humitos I'm not sure that getting rid of a DB constraint here is a good idea since it opens up for a potentially unwanted state that we didn't design for. So then we'd have to go and check all the places where this FK is in use 🔍 |
That seems like a good, easy first step. @benjaoming Want to take this on? |
Yes, all good and well-defined, would love to fix it 👍 |
Just updated the title to @humitos's point that it's not necessarily DB calls that cause the timeouts, but I'll update the issue with the cause once identified. |
This is probably hitting the same issue we had in #10446 where we needed to call a raw SQL query to avoid Django performing a |
Just noting that this also happens when a project has lots of versions (>1K). |
Users cannot delete projects with a lot of data or views and end up with 502s.
On the Dashboard's "Delete Project" page, we use Django's built-in
DeleteView
:readthedocs.org/readthedocs/projects/views/private.py
Lines 167 to 180 in 38fca65
It will call
.delete()
on the object to delete and then Django will call.delete()
on any referencing FK that hason_delete=models.CASCADE
This likely becomes an issue because of FKs in models with a lot of data, such as this:
readthedocs.org/readthedocs/analytics/models.py
Lines 55 to 63 in 38fca65
The solution is likely to clean up some relations with a bulk delete query here:
readthedocs.org/readthedocs/projects/models.py
Lines 498 to 504 in 38fca65
The text was updated successfully, but these errors were encountered: