Opened 13 years ago
Closed 13 years ago
#18151 closed Bug (invalid)
<model-name>.objects.filter function + sqlite => doesn't return and consumes increasing memory size
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
<model-name>.objects.filter function when used on a sqlite database(link given below) is eating up increasing memory size and doesn't return.
How to reproduce:
- Install Django 1.3.1 and CherryPy
- Extract http://dl.dropbox.com/u/1522424/leaky-sqlite-django-cleanedup.tar.gz
- Run as "python cherryserver.py".
You will find that the process consumes increasing memory size and doesn't return. Same database works fine with sqlite3 CLI, various sqlite GUI browsers and Python's in-built sqlite module.
Note:
See TracTickets
for help on using tickets.
You have 700000+ objects in the model you are trying to filter. I guess your filter doesn't filter that many objects away. Thus, you are going to fetch all those objects into memory and that is the likely reason for the leak. Do "if cache_stats.exists():" instead of "if cache_stats:". You will additionally need to do the deletion in batches (say, 10000 per call), or you will need to use raw SQL to do the deletes. Or, just wait it out and hope you have enough memory to do the deletion in one go.
I don't see any error we must fix here.