#23835: Infinite loop after squashing migrations
----------------------------+--------------------
     Reporter:  Twidi       |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Migrations  |    Version:  master
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+--------------------
 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

--
Ticket URL: <https://code.djangoproject.com/ticket/23835>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.2967acc5488d9592235759b94fae3138%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to