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

[7.2.1] Enforce and await cleanup in StarlarkBaseExternalContext #22814

Merged
merged 3 commits into from
Jun 20, 2024

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Jun 20, 2024

StarlarkBaseExternalContext now implements AutoCloseable and, in close():

  1. Cancels all pending async tasks.
  2. Awaits their termination.
  3. Cleans up the working directory (always for module extensions, on failure for repo rules).
  4. Fails if there were pending async tasks in an otherwise successful evaluation.

Previously, module extensions didn't do any of those. Repo rules did 1 and 4 and sometimes 3, but not in all cases.

This change required replacing the fixed-size thread pool in DownloadManager with virtual threads, thereby resolving a TODO about not using a fixed-size thread pool for the GrpcRemoteDownloader.

Work towards #22680
Work towards #22748

Closes #22772

PiperOrigin-RevId: 644669599
Change-Id: Ib71e5bf346830b92277ac2bd473e11c834cb2624

Closes #22775

`StarlarkBaseExternalContext` now implements `AutoCloseable` and, in `close()`:
1. Cancels all pending async tasks.
2. Awaits their termination.
3. Cleans up the working directory (always for module extensions, on failure for repo rules).
4. Fails if there were pending async tasks in an otherwise successful evaluation.

Previously, module extensions didn't do any of those. Repo rules did 1 and 4 and sometimes 3, but not in all cases.

This change required replacing the fixed-size thread pool in `DownloadManager` with virtual threads, thereby resolving a TODO about not using a fixed-size thread pool for the `GrpcRemoteDownloader`.

Work towards bazelbuild#22680
Work towards bazelbuild#22748

Closes bazelbuild#22772.

PiperOrigin-RevId: 644669599
Change-Id: Ib71e5bf346830b92277ac2bd473e11c834cb2624
@fmeum fmeum requested a review from a team as a code owner June 20, 2024 08:32
@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 Jun 20, 2024
@meteorcloudy
Copy link
Member

Hmm, not sure why this is failing:

--- /b/f/w/bazel-out/k8-fastbuild/bin/src/test/shell/bazel/jdeps_test.runfiles/_main/src/jdeps_modules.golden	2024-06-20 08:45:32.643192616 +0000
+++ jdeps-sorted	2024-06-20 09:00:45.733752481 +0000
@@ -2,7 +2,6 @@
 java.compiler
 java.instrument
 java.logging
-java.management
 java.naming
 java.sql
 java.xml

@fmeum fmeum changed the title Enforce and await cleanup in StarlarkBaseExternalContext [7.2.1] Enforce and await cleanup in StarlarkBaseExternalContext Jun 20, 2024
@fmeum
Copy link
Collaborator Author

fmeum commented Jun 20, 2024

@meteorcloudy Could you trigger a rerun? It does pass locally for me.

@meteorcloudy
Copy link
Member

I already did, but it didn't seem to help. Maybe RBE has some weird java toolchain setup?

@meteorcloudy
Copy link
Member

/cc @hvadehra in case you know something about this.

@hvadehra
Copy link
Member

The last time this exact failure happened was #20288 / bf0de1b

auto-merge was automatically disabled June 20, 2024 12:34

Head branch was pushed to by a user without write access

@hvadehra
Copy link
Member

hvadehra commented Jun 20, 2024

(I should have clarified the fix from back then is apparently already in 7.x thanks to 4362d97, but bumping it further could work. If it doesn't, I can take a stab at debugging)

@meteorcloudy
Copy link
Member

I also don't mind disabling this test on RBE since we already have it covered on other platforms.

@@ -72,7 +72,7 @@ function test_jdeps() {
# src/test/shell/bazel/jdeps_class_denylist.txt.
find . -type f -iname \*class | \
grep -vFf "$denylist" | \
Copy link
Member

Choose a reason for hiding this comment

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

adding a sort -r after this should workaround the problem (for now). I'll look into a principled fix later.

auto-merge was automatically disabled June 20, 2024 16:31

Head branch was pushed to by a user without write access

@iancha1992 iancha1992 added this pull request to the merge queue Jun 20, 2024
@iancha1992 iancha1992 removed this pull request from the merge queue due to a manual request Jun 20, 2024
@Wyverald Wyverald added this pull request to the merge queue Jun 20, 2024
Merged via the queue into bazelbuild:release-7.2.1 with commit 8fb4dce Jun 20, 2024
32 checks passed
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Jun 20, 2024
@fmeum fmeum deleted the 22775-cherry branch June 20, 2024 18:56
keertk added a commit to bazel-io/bazel that referenced this pull request Jun 20, 2024
[7.2.1] Enforce and await cleanup in `StarlarkBaseExternalContext` (bazelbuild#22814)
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.

None yet

4 participants