Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not print errors when repository rules are interrupted #20023

Closed
wants to merge 1 commit into from

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Nov 2, 2023

When the user interrupts a build with Ctrl+C during the download or extraction of a file, no Starlark error should be printed. This is achieved by propagating InterruptedExceptions instead of failing the repository rule with an IOException.

When the user interrupts a build with Ctrl+C during the download or
extraction of a file, no Starlark error should be printed. This is
achieved by propagating `InterruptedException`s instead of failing the
repository rule with an `IOException`.
@github-actions github-actions bot added awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. labels Nov 2, 2023
Copy link
Member

@Wyverald Wyverald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to trust that you did some testing, as I'm not really sure how the interaction works here :)

@Wyverald Wyverald added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Nov 2, 2023
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 2, 2023

I'm going to trust that you did some testing, as I'm not really sure how the interaction works here :)

I tested interrupting downloads and extractions and they both interrupted cleanly.

Based on the contract of SkyFunction#compute, swallowing InterruptedExceptions caused by you and not your dependencies does seem wrong, which gives me some confidence that this is also conceptually correct.

I would still suggest not to cherry pick this into 7.0.0.

@katre
Copy link
Member

katre commented Nov 2, 2023

Another case of #18629.

@copybara-service copybara-service bot closed this in a2d3f20 Nov 2, 2023
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Nov 2, 2023
@fmeum fmeum deleted the fix-interrupts branch November 2, 2023 21:11
@fmeum
Copy link
Collaborator Author

fmeum commented Nov 6, 2023

@lberki While taking a deeper look at how Skyframe handles interrupts, I noticed that it seems to drop the Skyframe compute state only if a SkyFunction errors out (https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/skyframe/AbstractParallelEvaluator.java;l=479;drc=69359279d4ff40b25b6a69219f0576bae19f0297;bpv=1;bpt=1?q=Skyfunc&ss=bazel%2Fbazel), but not when it is interrupted. Do you know what the precise invariant on state maintained through interrupts is?

@lberki
Copy link
Contributor

lberki commented Nov 7, 2023

I don't, not off the bat. Maybe @justinhorvitz does?

@justinhorvitz
Copy link
Contributor

I think we haven't thought to clear the compute state on interrupt because an interrupted skyframe thread typically means that the whole evaluation is being interrupted, and the state cache is per-evaluation. Do you have a case where there's an interrupt but the overall evaluation proceeds?

Tagging @haxorz because he was more involved in the state cache implementation.

@fmeum
Copy link
Collaborator Author

fmeum commented Nov 7, 2023

If that's the case then all is well: I was worried about state being preserved across evaluations, and with it the possibly invalid contents of the external repository. Just for the sake of my own education, could you point me to where this per-evaluation state clearing happens?

@justinhorvitz
Copy link
Contributor

AbstractParallelEvaluator#stateCache is initialized per evaluator instance. A new instance is created for each evaluation.

@fmeum
Copy link
Collaborator Author

fmeum commented Dec 22, 2023

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Dec 22, 2023
@meteorcloudy
Copy link
Member

@fmeum You can now do @bazel-io flag <version> to indicate which release you want this to be cherry picked. I guess this one will be 7.1

@meteorcloudy
Copy link
Member

@bazel-io fork 7.1.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Dec 22, 2023
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Dec 22, 2023
When the user interrupts a build with Ctrl+C during the download or extraction of a file, no Starlark error should be printed. This is achieved by propagating `InterruptedException`s instead of failing the repository rule with an `IOException`.

Closes bazelbuild#20023.

PiperOrigin-RevId: 578869315
Change-Id: I9dd901ed87ed00c239599877816c6836688c1e16
github-merge-queue bot pushed a commit that referenced this pull request Jan 9, 2024
…0662)

When the user interrupts a build with Ctrl+C during the download or
extraction of a file, no Starlark error should be printed. This is
achieved by propagating `InterruptedException`s instead of failing the
repository rule with an `IOException`.

Closes #20023.

Commit
a2d3f20

PiperOrigin-RevId: 578869315
Change-Id: I9dd901ed87ed00c239599877816c6836688c1e16

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Co-authored-by: Xùdōng Yáng <wyverald@gmail.com>
Co-authored-by: Ian (Hee) Cha <heec@google.com>
@iancha1992
Copy link
Member

The changes in this PR have been included in Bazel 7.1.0 RC1. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants