#17014: prefetch_related infinite recursion by default managers -------------------------------------+------------------------------------- Reporter: akaariai | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 1.3 (models, ORM) | Resolution: Severity: Normal | Triage Stage: Keywords: | Unreviewed Has patch: 0 | Needs documentation: 1 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by akaariai):
* cc: anssi.kaariainen@… (added) * needs_better_patch: => 0 * needs_docs: => 1 * needs_tests: => 0 Comment: Ok, I have confirmed this against both #17003 patch and trunk. Recursion will eat all your memory and OOM killer will get into action (after some trashing). The attached test cases show the problem. I think the patch will apply to #17003, too. I will work on a patch against trunk next. My idea is to track added prefetches by key (model, to_attr) where to_attr will be currently the name of the related manager we are caching the results in. If we are adding a prefetch related lookup into the query and the lookup came from default manager, we will bail out. This way it is possible to traverse the same path intentionally, but default manager recursion will be avoided. That is, we can define that we want People -> friends -> friends, but if we have default prefetch for friends, we will bail out because lookup People -> friends has been added to the query already. I will try to do one against #17003, too. -- Ticket URL: <https://code.djangoproject.com/ticket/17014#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.