Skip to content

Commit

Permalink
Prevent write completion starvation for duplicates
Browse files Browse the repository at this point in the history
When a duplicate output stream is detected, we must signal the
writeWinner (because the write exists) and onInsert (because it was
inserted) for an output stream creation. If we're racing, we should be
eventually convergent, but this absolutely fixes a hang which occurs on
this sentinel stream's return into getOutput, where the future might
never be triggered otherwise.
  • Loading branch information
werkt authored and 80degreeswest committed May 31, 2024
1 parent 481d627 commit bb1f766
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/build/buildfarm/cas/cfc/CASFileCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -2637,6 +2637,9 @@ private CancellableOutputStream putImpl(
onInsert,
isReset);
if (out == DUPLICATE_OUTPUT_STREAM) {
log.log(Level.FINER, format("duplicate output stream, completing %s for %s", key, writeId));
writeWinner.get();
onInsert.run();
return null;
}
log.log(Level.FINER, format("entry %s is missing, downloading and populating", key));
Expand Down

0 comments on commit bb1f766

Please sign in to comment.