Skip to content

Commit

Permalink
[7.2.1] Ensure that downloads are cancelled on repo rule restart (#22758
Browse files Browse the repository at this point in the history
)

When a repository rule is restarted due to memory pressure, all its
downloads must be interrupted. While this happened for
`repository_ctx.download`, the `download_and_extract` method did not
register its `PendingTask`. Since downloads happen on a separate
executor, they would continue even through restarts, leading to warnings
(see below) or even left over download temp directories.

```
WARNING: Download from https://github.com/uutils/coreutils/releases/download/0.0.26/coreutils-0.0.26-aarch64-apple-darwin.tar.gz failed: class java.io.FileNotFoundException /private/var/tmp/_bazel_fmeum/0465a0857e26a35c072f48ab751a1794/external/aspect_bazel_lib~~toolchains~coreutils_darwin_arm64/temp2576567839043404337/coreutils-0.0.26-aarch64-apple-darwin.tar.gz (No such file or directory)
```

Closes #22748.

PiperOrigin-RevId: 643389876
Change-Id: Ia2cab4b4d73340379c17d4a1e5c327ff43505050

Commit
2fb187f

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
  • Loading branch information
bazel-io and fmeum authored Jun 17, 2024
1 parent 873d55f commit d8cd073
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,18 @@ public StructImpl downloadAndExtract(
env.getListener(),
envVariables,
getIdentifyingStringForLogging());
// Ensure that the download is cancelled if the repo rule is restarted as it runs in its own
// executor.
PendingDownload pendingTask =
new PendingDownload(
/* executable= */ false,
allowFail,
outputPath,
checksum,
checksumValidation,
pendingDownload,
thread.getCallerLocation());
registerAsyncTask(pendingTask);
downloadedPath = downloadManager.finalizeDownload(pendingDownload);
} catch (IOException e) {
env.getListener().post(w);
Expand Down

0 comments on commit d8cd073

Please sign in to comment.