Unverified Commit c947937b authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

[turbopack] only remove followers if they are actually removed as children (#98843)

## What

When removing edges, only enqueue `lost follower` jobs when we actually
remove children.

## Why

GC can race with other kinds of task completion which also remove
outgoing edges.

If task completion drops a child from a task that also becomes
collectible. Then it is possible for there to be an enqueued
CleanupOldEdges job at the time GC runs. Then we will have two jobs that
remove children, only one will succeed but both will enqueue
`InnerOfUppersLostFollowersJob` for all the chidren. This can lead to
panics since one of those jobs will fail to remove the follower

The fix is simple, only remove tasks as followers when you actually
removed them as children.
parent 645cae03
...@@ -167,15 +167,18 @@ impl CleanupOldEdgesOperation { ...@@ -167,15 +167,18 @@ impl CleanupOldEdgesOperation {
let parent_is_transient = task_id.is_transient(); let parent_is_transient = task_id.is_transient();
let mut removed_durable = SmallVec::<[TaskId; 4]>::new(); let mut removed_durable = SmallVec::<[TaskId; 4]>::new();
let mut removed_transient = SmallVec::<[TaskId; 4]>::new(); let mut removed_transient = SmallVec::<[TaskId; 4]>::new();
for child_id in children.iter() { children.retain(|child_id| {
if task.remove_children(child_id) { if task.remove_children(child_id) {
if parent_is_transient || child_id.is_transient() { if parent_is_transient || child_id.is_transient() {
removed_transient.push(*child_id); removed_transient.push(*child_id);
} else { } else {
removed_durable.push(*child_id); removed_durable.push(*child_id);
} }
true
} else {
false
} }
} });
if !removed_durable.is_empty() { if !removed_durable.is_empty() {
queue.push(AggregationUpdateJob::AdjustParentCount { queue.push(AggregationUpdateJob::AdjustParentCount {
task_ids: removed_durable, task_ids: removed_durable,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment