-
-
Notifications
You must be signed in to change notification settings - Fork 335
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
Request.objects.all().delete()
is dangerous
#711
Comments
I don't think that's true. It will retrieve data from the data if it is evaluated (e.g. through Your pull request seems to tackle a different problem - since django-silk may be continually profiling and writing new rows into the database, it may conflict with DELETE operation unless the rows to be deleted are separate from newly written rows, hence the deadlock issues discussed in #265 and #294. |
@albertyw I've thought like so, but no, django loads all to db because it needs to cascade delete related models. The fix might also fix the deadlock problem. The below is the raw SQL when I called
|
It is possible to use |
django-silk/silk/models.py
Lines 167 to 170 in 1cb4623
If you call all() on a table with many rows, it will retrieve all the data at once, which will likely result in out-of-memory (OOM) errors.
I previously used Celery to call this function to avoid deadlock, as suggested in the referenced comment. However, due to OOM errors, our scheduler failed to clear the database, leading to excessive database usage.
I recommend setting a limit and deleting the rows recursively instead. I will submit a pull request to address this issue.
The text was updated successfully, but these errors were encountered: