﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
8115	Infinite loop trying to delete circularly referent models	Kenneth Arnold	nobody	"[http://conceptnet.media.mit.edu/ ConceptNet] has {{{Assertion}}}s, {{{RawAssertion}}}s, and {{{Rating}}}s (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."		closed	Database layer (models, ORM)	dev		fixed	1.0-blocker	kenneth.arnold@…	Accepted	1	0	0	0	0	0
