Infinite loop trying to delete circularly referent models
|Reported by:||Kenneth Arnold||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Ratings (among other models). The relationship looks like:
RawAssertion: assertion = ForeignKey(Assertion, null=True) Rating: assertion = ForeginKey(Assertion) Assertion: canonical = ForeignKey(RawAssertion)
Assertion runs into an infinite loop in
CollectedObjects.ordered_keys. The second time through the loop, when dealing with
model=Rating, it has no children, but we shouldn't be setting
found=True, because there's still a cyclic dependency. We should be able to tell that because it's already in
I tried to come up with a test case for this, but I couldn't make it fail. You can certainly reproduce it by downloading ConceptNet yourself.
Attached patch fixes the obvious problem by causing it to raise the
CyclicDependency exception properly. By "fix", I mean it gets to the real problem: there's a cycle. Eventually we'll need to look at the
null flags on the relations to figure out where to break the cycle, but that's a separate issue.