Skip to content

Project: Deleting a project cascades computations that time out #10040

@benjaoming

Description

@benjaoming

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:

class ProjectDelete(UpdateChangeReasonPostView, ProjectMixin, DeleteView):
success_message = _('Project deleted')
template_name = 'projects/project_delete.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['is_superproject'] = (
self.object.subprojects.all().exists()
)
return context
def get_success_url(self):
return reverse('projects_dashboard')

It will call .delete() on the object to delete and then Django will call .delete() on any referencing FK that has on_delete=models.CASCADE

This likely becomes an issue because of FKs in models with a lot of data, such as this:

class PageView(models.Model):
"""PageView counts per day for a project, version, and path."""
project = models.ForeignKey(
Project,
related_name='page_views',
on_delete=models.CASCADE,
)

The solution is likely to clean up some relations with a bulk delete query here:

def delete(self, *args, **kwargs): # pylint: disable=arguments-differ
from readthedocs.projects.tasks.utils import clean_project_resources
# Remove extra resources
clean_project_resources(self)
super().delete(*args, **kwargs)

Front logo Front conversations

Metadata

Metadata

Assignees

Labels

AcceptedAccepted issue on our roadmapBugA bug

Type

No type

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions