Tighten invariants around dirtiness checking. We should never need to create a child that's being checked by a parent (that was a legacy of when we delegated to enqueueChild), and such a child that is being checked should always be dirty or done, never fresh.
MOS_MIGRATED_REVID=149136909
@@ -262,8 +262,9 @@ public final class ParallelEvaluator implements Evaluator {
// usual, but we can't, because then the ErrorTransienceValue would remain as a dep,
// which would be incorrect if, for instance, the value re-evaluated to a non-error.
state.forceRebuild();
- graph.get(
- skyKey, Reason.RDEP_REMOVAL, ErrorTransienceValue.KEY).removeReverseDep(skyKey);
+ graph
+ .get(skyKey, Reason.RDEP_REMOVAL, ErrorTransienceValue.KEY)
+ .removeReverseDep(skyKey);
return DirtyOutcome.NEEDS_EVALUATION;
}
if (!evaluatorContext.keepGoing()) {
@@ -307,14 +308,20 @@ public final class ParallelEvaluator implements Evaluator {
// always the last dep).
state.addTemporaryDirectDepsGroupToDirtyEntry(directDepsToCheck);
- // TODO(bazel-team): If this signals the current node, consider falling through to the
- // VERIFIED_CLEAN case below directly, without scheduling a new Evaluate().
- for (Map.Entry<SkyKey, ? extends NodeEntry> e :
- graph
- .createIfAbsentBatch(skyKey, Reason.ENQUEUING_CHILD, directDepsToCheck)
- .entrySet()) {
+ Map<SkyKey, ? extends NodeEntry> oldChildren =
+ graph.getBatch(skyKey, Reason.ENQUEUING_CHILD, directDepsToCheck);
+ Preconditions.checkState(
+ oldChildren.size() == directDepsToCheck.size(),
+ "Not all old children were present: %s %s %s %s",
+ skyKey,
+ state,
+ directDepsToCheck,
+ oldChildren);
+ for (Map.Entry<SkyKey, ? extends NodeEntry> e : oldChildren.entrySet()) {
SkyKey directDep = e.getKey();
NodeEntry directDepEntry = e.getValue();
+ // TODO(bazel-team): If this signals the current node, consider falling through to the
+ // VERIFIED_CLEAN case below directly, without scheduling a new Evaluate().
enqueueChild(skyKey, state, directDep, directDepEntry, /*depAlreadyExists=*/ true);
}
return DirtyOutcome.ALREADY_PROCESSED;
