﻿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
23835	Infinite loop after squashing migrations	"Stephane ""Twidi"" Angel"	nobody	"Take a ""complex"" dependency graph:

{{{
app_a:        0001 <-
                     \
app_b:        0001 <- x 0002 <-
               /               \
app_c:   0001<-  <------------- x 0002
}}}

And squash migrations on on '''app_c'''.

Now we should have a '''CircularDependencyError'''.

But we have an '''infinite loop'''.

Note that if ""'''app_a'''"" was named ""'''app_d'''"", the '''CircularDependencyError''' would have been raised.

It's because of the ""'''sorted'''"" on the '''dfs''' function, in '''django.db.migrations.graph'''.

Note that without this ""'''sorted'''"", the infinite loop could happen randomely because we have a set. The problem is not here.

Condition to reproduce this bug: having a circular loop, and an node in this loop having a dependency '''that has no dependency''', which will reset the ""'''path'''"" list.

Indeed, if you remove  the dependency of '''app_b.0002''' on '''app_a''', the '''CircularDependencyError''' is raised.

You can see the test case here: https://github.com/twidi/django/compare/squashing-infinite-loop
"	Bug	closed	Migrations	dev	Normal	fixed		mail@…	Accepted	0	0	0	0	0	0
