Ensure that debug error pages never evaluate QuerySets
|Reported by:||Kenneth Arnold||Owned by:||Malcolm Tredinnick|
|Severity:||Keywords:||debug slow queryset repr memory|
|Cc:||kenneth.arnold@…, ehs@…||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The local variable display on debug 500 pages unintentionally evaluates
QuerySets. At best, the result is a delay . At worst, the attempted evaluation may cause another exception, which will mask the root cause of the error.
Based on my suggestions, Mike Axiak of MIT ESP wrote the attached code (originally bundled with other code). I have attempted to factor out this part in a form that could conceivably apply to trunk. Patch attached.
 The load delay may be significantly greater than a normal page load, for two reasons:
- The debug page will include all local
QuerySets, even if some of them were intermediary results in constructing the final
QuerySet. This is particularly bad if the intermediate one does not yet have a row limit; I have occasionally found a debug page iterating over an entire huge table because of this.
- The model
ForeignKeyfields that may not be used on the page. The patch doesn't address this yet.
Change History (20)
comment:1 Changed 9 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Design decision needed|
comment:14 Changed 8 years ago by
|Owner:||changed from nobody to Malcolm Tredinnick|
|Status:||new → assigned|