From b9af9024e00317d93c48d37bebf60698589da3bc Mon Sep 17 00:00:00 2001 From: Brandur Date: Fri, 9 Oct 2026 23:20:20 -0500 Subject: [PATCH] Fix intermittent test failure related to Ractors Here, we avoid running a particular Ractor test case for Ruby < 4. There was an outstanding bug in 3.4 related to a Ractor scheduling deadlock that was fixed for Ruby 4 but not backported: https://bugs.ruby-lang.org/issues/20905 --- ruby/docs/README.md | 5 +++++ ruby/spec/ractor_spec.rb | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/ruby/docs/README.md b/ruby/docs/README.md index 84836132f..24d993b9b 100644 --- a/ruby/docs/README.md +++ b/ruby/docs/README.md @@ -751,6 +751,11 @@ Load River and worker definitions in the main Ractor before spawning others. Eac Database drivers, Active Record, Sequel, and optional dependencies such as Fugit still need their own Ractor compatibility. Job timeouts also depend on Ruby and the `timeout` gem: the test suite exercises them on Ruby 4 with `timeout` 0.6.1; tests on older Rubies disable job timeouts. `WorkerRunner` handles process-wide signals and must run on the main thread of the main Ractor. +Ruby 3.3 and 3.4 can deadlock while scheduling threads inside Ractors, even +without River ([Ruby bug #20905](https://bugs.ruby-lang.org/issues/20905), fixed +in Ruby 4). The test suite skips the producer/maintenance lifecycle test on +those versions; insertion and synchronous worker checks still run. + Ruby 4.0.2 with `timeout` 0.6.1 can intermittently deadlock during VM shutdown while terminating Ractors and their timeout helper threads, even after work finishes successfully. This reproduces without River. Tests bypass that shutdown diff --git a/ruby/spec/ractor_spec.rb b/ruby/spec/ractor_spec.rb index d7053364b..0853d745f 100644 --- a/ruby/spec/ractor_spec.rb +++ b/ruby/spec/ractor_spec.rb @@ -126,6 +126,13 @@ def worker.work(job) end it "starts producer/maintenance threads and stops within a non-main Ractor" do + # Ruby's M:N scheduler can lose a runnable Ractor when a thread exits, + # especially with few CPUs. This reproduces without River and is fixed in + # Ruby 4: https://bugs.ruby-lang.org/issues/20905. + if RUBY_VERSION.start_with?("3.3.", "3.4.") + skip "Ruby 3.3/3.4's threaded Ractor scheduler can deadlock (ruby-lang #20905)" + end + in_ractor <<~'RUBY' config = River::Config.new( workers: River::Workers.new.add(RactorTestWorker), queues: {default: 1},