[PL-133119] Topological sort before rewriting aggregate jobs #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Given the leaf jobs
packages.foo
&packages.bar
, an aggregate jobaggregate0
withand an aggregate job
aggregate1
withthen it may happen depending on the order of evaluation that
aggregate1
depends on the old derivation ofaggregate0
(i.e. the one without rewritten constituents) and doesn't depend onpackages.foo
andpackages.bar
because it was rewritten beforeaggregate0
was rewritten.Using a toposort (derived from the one in CppNix's libutil) to solve that. Cycles are a hard error, then all aggregates are failed to make sure we don't finish one of those too early.
This also extracts the code into a few helper functions and a slightly better data structure, otherwise this would've gotten too chaotic.