File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -521,7 +521,22 @@ where
521521 }
522522
523523 // Check if the memo is still a cycle head and hasn't changed
524- // to a normal cycle participant.
524+ // to a normal cycle participant. This is to force re-execution in
525+ // a scenario like this:
526+ //
527+ // * There's a nested cycle with the outermost query A
528+ // * B participates in the cycle and is a cycle head in the first few iterations
529+ // * B becomes a non-cycle head in a later iteration
530+ // * There's a query `C` that has `B` as its cycle head
531+ //
532+ // The crucial point is that `B` switches from being a cycle head to being a regular cycle participant.
533+ // The issue with that is that `A` doesn't update `B`'s `iteration_count `when the iteration completes
534+ // because it only does that for cycle heads (and collecting all queries participating in a query would be sort of expensive?).
535+ //
536+ // When we now pull `C` in a later iteration, `validate_same_iteration` iterates over all its cycle heads (`B`),
537+ // and check if the iteration count still matches. Which is the case because `A` didn't update `B`'s iteration count.
538+ //
539+ // That's why we also check if `B` is still a cycle head in the current iteration.
525540 if !cycle_heads. contains ( & head_database_key) {
526541 return false ;
527542 }
You can’t perform that action at this time.
0 commit comments