Skip to content

Commit

Permalink
Fix data race on prefetcher.
Browse files Browse the repository at this point in the history
Individual file prefetches within a single prefetchFiles() can race against
each other, so they must synchronize when writing to the DirectoryContext.
  • Loading branch information
tjgq committed Mar 7, 2023
1 parent 3b79eeb commit c99c5ae
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -95,7 +94,7 @@ public abstract class AbstractActionInputPrefetcher implements ActionInputPrefet

/** Keeps track of output directories written to by a single prefetcher call. */
private final class DirectoryContext {
private final HashSet<Path> dirs = new HashSet<>();
private final Set<Path> dirs = Sets.newConcurrentHashSet();

/**
* Adds to the set of directories written to by the prefetcher call associated with this
Expand Down

0 comments on commit c99c5ae

Please sign in to comment.