Repository navigation
fix: LazyValue no longer raises ThreadError for concurrent fibers under a fiber scheduler - #119
Closed
HolyWalley wants to merge 1 commit into
Closed
HolyWalley wants to merge 1 commit into
HolyWalley wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…er a fiber scheduler LazyValue identified the computing caller by Thread.current. Under a fiber scheduler (Falcon, Async) every fiber on a thread shares it, so a second fiber calling #get during another fiber's computation was taken for re-entry and raised "deadlock: tried to call LazyValue#get from its own computation". Under a scheduler the caller is now the fiber; without one it stays the thread, so thread-only code behaves as before.
HolyWalley
force-pushed
the
fix/lazy-value-fiber-scheduler
branch
from
October 28, 2026 13:29
2c5bcd0 to
24dc268
Compare
Author
|
Superseded by #120: the same commit, opened from my personal fork instead of the company one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LazyValueidentifies the caller that is computing byThread.current. Under a fiber scheduler (Falcon, Async), every fiber on a thread shares oneThread.current. So when a second fiber calls#getwhile another fiber's computation is waiting on I/O,wait_computetreats it as re-entry and raises:Nothing is actually deadlocked. The second fiber could simply wait: since Ruby 3.0,
MutexandConditionVariableblock per fiber under a scheduler.We hit this in production on GKE with Falcon. Parallel requests that sign GCS URLs share one metadata-server
LazyValue(ComputeMetadata, viaexpiring_value). One request computes and the others fail with the error above.Fix: a private
current_ownerhelper replaces the four uses ofThread.current(enter_compute,wait_compute,handle_success,handle_failure). It returnsFiber.currentwhile a fiber scheduler is set, andThread.currentotherwise.Enumerator#nextwhose body calls#get): it still raisesThreadError. A plainFiber.currentwould hang there, because with no scheduler the waiting fiber blocks its thread.ThreadError.Tests: two new tests use a minimal
Fiber::Schedulerdefined in the test file, so no new dependency is needed:Without the fix, the first test fails with the
ThreadErrorabove.toys testandtoys rubocoppass on Ruby 3.2, 3.3, 3.4 and 4.0. The exception isComputeSMBIOS"gets data on Linux", which also fails on unchangedmainin a Docker container with no DMI data.🤖 Generated with Claude Code