Code

Opened 8 years ago

Closed 7 years ago

#2549 closed defect (duplicate)

django.db.models.fill_table_cache will dead loop if with circular Foreign Keys

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: critical Keywords: loop db fill_table_cache foreign key, qs-rf
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This function might fall into dead loop if there's a loop in the Foreign Key Relationships.

Attachments (0)

Change History (9)

comment:1 Changed 8 years ago by anonymous

  • Summary changed from django.db.models.fill_table_cache to django.db.models.fill_table_cache might dead loop

comment:2 Changed 8 years ago by anonymous

  • Keywords loop db fill_table_cache foreign key added

I find this happens to me (without fail) using this very simple Model:

from django.db import models

class A(models.Model):
    B = models.ForeignKey('B')
    class Admin:
        list_display = ('B',)

class B(models.Model):
    A = models.ForeignKey('A')
    class Admin:
        pass

Clicking on "A" in the Admins Interface loops forever. Clicking on "B" works just fine. I don't know a lot about the internals but I get the feeling that the Admin interface is not the problem, but that "fill_table_cache" is. I would consider changing this to a "Blocker" as this is not that uncommon. If anyone knows where I can find more information on this, please attach it to this ticket.

comment:3 Changed 8 years ago by anonymous

  • Summary changed from django.db.models.fill_table_cache might dead loop to django.db.models.fill_table_cache will dead loop if with circular Foreign Keys

Ouch! My model was more like A->B, B->C, C->A. Same result.

comment:4 Changed 7 years ago by adrian

  • Component changed from Cache system to Database wrapper
  • Owner changed from jacob to adrian

comment:5 Changed 7 years ago by anonymous

I've opened this 4 month ago, but it's still open!

So I decided I will solve it myself!! I'll use this weekend to make a patch. I've made one 4 month ago but I can't find it now.

comment:6 Changed 7 years ago by anonymous

Hey Mr. Anon -

Waiting for that patch :)

comment:7 Changed 7 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

comment:8 Changed 7 years ago by mtredinnick

  • Keywords key, qs-rf added; key removed

comment:9 Changed 7 years ago by PhiR

  • Resolution set to duplicate
  • Status changed from new to closed

#3288 is a specific case of this but has a patch fixing this issue for both SVN and 0.96. Adding regression tests too.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.