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

Fix a deadlock involving scheduler.all_digests, and add a note. (cherrypick of #11723) #13149

Merged
merged 1 commit into from
Oct 7, 2021

Conversation

stuhood
Copy link
Member

@stuhood stuhood commented Oct 7, 2021

Problem

By chance, a garbage collection thread started up and called lease_files_in_graph while I happened to be running Pants in the foreground. This caused a deadlock because lease_files_in_graph was not releasing the GIL before touching the Graph (via the Scheduler)... and foreground interactions with the Graph frequently need to acquire the GIL to check for equality.

Solution

Move the problematic call to scheduler.all_digests() under allow_threads and add a note. Additionally, move one other potentially-problematic method call under allow_threads.

Result

A rare (hopefully?) deadlock is prevented. See #11722 for how we might make this less likely in the future.

[ci skip-build-wheels]
[ci skip-jvm-tests]

…sbuild#11723)

### Problem

By chance, a garbage collection thread started up and called `lease_files_in_graph` while I happened to be running Pants in the foreground. This caused a deadlock because `lease_files_in_graph` was not releasing the GIL before touching the `Graph` (via the `Scheduler`)... and foreground interactions with the `Graph` frequently need to acquire the GIL to check for equality.

### Solution

Move the problematic call to `scheduler.all_digests()` under `allow_threads` and add a note. Additionally, move one other potentially-problematic method call under `allow_threads`.

### Result

A rare (hopefully?) deadlock is prevented. See pantsbuild#11722 for how we might make this less likely in the future.

[ci skip-build-wheels]# Delete this line to force CI to run the JVM tests.
[ci skip-jvm-tests]
@stuhood stuhood merged commit a3bf5e4 into pantsbuild:1.30.x Oct 7, 2021
@stuhood stuhood deleted the stuhood/pick-11723-for-1.30.x branch October 7, 2021 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants