Skip to content

Retry interrupted waits in io_wait and process_wait - #469

Merged
ioquatix merged 11 commits into
mainfrom
fix-stale-unblock-retry
Aug 26, 2026
Merged

Retry interrupted waits in io_wait and process_wait#469
ioquatix merged 11 commits into
mainfrom
fix-stale-unblock-retry

Conversation

@tavianator

@tavianator tavianator commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Fixes: #467

Summary

  • Retry io_wait after a stale selector wake-up while preserving the original timeout.
  • Retry process_wait when the selector returns false, indicating that the native wait was interrupted before process completion.
  • Preserve nil from process_wait, including legitimate Process::WNOHANG results.
  • Require io-event ~> 1.21, which provides consistent interrupted-process-wait behavior across native backends.
  • Add backend-independent regression coverage for Async's retry policy.

Scope

io-event owns the native interruption and cancellation contract; Async owns the higher-level retry policy. socketry/io-event#215 fixed modern io_uring cancellation and was released in io-event v1.21.0.

The separate threaded process-wait behavior is not worked around here. socketry/io-event#212 adds test-only coverage on Ruby 4.0 and newer. Ruby 3.3 and 3.4 remain skipped there pending the CRuby backports:

Testing

  • BUNDLE_MIRROR__RUBYGEMS__ORG=https://rubygems.org BUNDLE_GEMFILE=gems.rb bundle exec bake test
  • 541 tests passed with 1,193 assertions on Ruby 4.0.6 using io-event 1.21.0.
  • CI passes across CRuby, selector backends, worker-pool coverage, lint, documentation, CodeQL, and external tests.
  • The JRuby timeout cascade and TruffleRuby Fiber.set_scheduler failure reproduce identically on the previous commit (57ffab4) and are unrelated to this update.

Types of Changes

  • Bug fix.

Contribution

Comment thread lib/async/scheduler.rb Outdated
@samuel-williams-shopify

samuel-williams-shopify commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

The final split is now explicit: Async retries only selector-level stale wake-ups (io_wait and an explicit false from native process_wait). It preserves nil, including legitimate Process::WNOHANG results. The threaded fallback is not worked around in Async or io-event; socketry/io-event#212 adds Ruby 4.0+ regression coverage while ruby/ruby#18502 and ruby/ruby#18503 track the Ruby 3.3/3.4 backports.

@samuel-williams-shopify samuel-williams-shopify changed the title Tolerate spurious wake-ups in io_wait and process_wait Retry stale selector wake-ups in io_wait and process_wait Aug 26, 2026
tavianator and others added 5 commits August 26, 2026 16:51
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
@samuel-williams-shopify samuel-williams-shopify changed the title Retry stale selector wake-ups in io_wait and process_wait Retry interrupted waits in io_wait and process_wait Aug 26, 2026
@ioquatix
ioquatix merged commit 78f3ce6 into main Aug 26, 2026
77 of 81 checks passed
@ioquatix
ioquatix deleted the fix-stale-unblock-retry branch August 26, 2026 10:59
@ioquatix ioquatix added this to the v2.45.0 milestone Aug 26, 2026
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.

Sleep/IO timeout can return early under concurrent per-fiber timeouts (async 2.42.0)

3 participants