Skip to content

ThreadError can't create Thread: Resource temporarily unavailable when bumping from 5.23.0 to 5.24.0 #2651

@alexevanczuk

Description

@alexevanczuk

Issue Description

5.23.0...5.24.0

It's not clear to me exactly what is going on, but in our system 5.23.0 passes all tests with no issue, but once we upgrade to 5.24.0, all tests fail, with errors like this:

/home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:219:in 'Thread#initialize': can't create Thread: Resource temporarily unavailable (ThreadError)
	from /home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:219:in 'Thread.new'
	from /home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:219:in 'block (3 levels) in Parallel.in_threads'
	from <internal:numeric>:257:in 'Integer#times'
	from /home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:218:in 'block (2 levels) in Parallel.in_threads'
	from /home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:217:in 'Thread.handle_interrupt'
	from /home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:217:in 'block in Parallel.in_threads'
	from /home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:216:in 'Thread.handle_interrupt'
	from /home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:216:in 'Parallel.in_threads'
	from /home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:434:in 'Parallel.work_in_threads'
	from /home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:[28](https://github.com/withbridge/monorail/actions/runs/15636743343/job/44053753933#step:12:29)7:in 'Parallel.map'
	from /home/runner/work/monorail/monorail/vendor/bundle/ruby/3.4.0/gems/parallel-1.25.1/lib/parallel.rb:235:in 'Parallel.each'

Other tests won't have that issue, but weirdly I'll just see:

Error: The operation was canceled.

At the bottom of our CI output (we use GitHub Actions).

Other tests are failing because of what appears to be some corrupt ActiveRecord connection (not sure exactly, it's application specific errors that we don't have on 5.23.0).

A lot of our test threads are also just hanging.

Is it possible some threading isn't being cleaned up properly?

We're using rails 8.0.2, Ruby 3.4.2

Reproduction Steps

Bump to 5.24.0

Expected Behavior

No threading issues

Actual Behavior

Lots of thread-related issues

Ruby Version

3.4.2

SDK Version

5.24.0

Integration and Its Version

No response

Sentry Config

Rails.application.config.to_prepare do
  Sentry.init do |config|
    config.breadcrumbs_logger = [:active_support_logger, :http_logger]
    config.enabled_environments = %w[production sandbox]
    config.logger.level = Logger::INFO
    if Sandbox.true?
      config.environment = "sandbox"
    end
    filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters)
    config.before_send =
      lambda do |event, _hint|
        filter.filter(event.to_hash)
      end
  end
end

Metadata

Metadata

Assignees

Labels

Projects

Status

Waiting for: Product Owner

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions