Infinite loop trying to delete circularly referent models
|Reported by:||kcarnold||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
ConceptNet has Assertions, RawAssertions, and Ratings (among other models). The relationship looks like:
RawAssertion: assertion = ForeignKey(Assertion, null=True) Rating: assertion = ForeginKey(Assertion) Assertion: canonical = ForeignKey(RawAssertion)
Deleting an 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 dealt_with.
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.
Change History (8)
Changed 7 years ago by kcarnold
comment:1 Changed 7 years ago by jacob
- milestone set to 1.0
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted