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
How can I fix "WARNING: Detected 2 Thread(s) started in app boot:" with concurrent-ruby? #2237
Comments
I've also opened an issue on concurrent-ruby: ruby-concurrency/concurrent-ruby#868, to see if they have any thoughts |
I think you need to show your Puma config and maybe also the full code to reproduce this, for someone to be able to advise you properly. |
I'm interested to hear what the concurrent-ruby people think. If they weren't creating threads at require-time, this wouldn't be an issue. |
As a possible (temporary?) workaround, I noticed that I get this warning on startup using v1.1.6 of concurrent-ruby (as the original post above also did) but when I downgraded to 1.1.5 the warning went away. |
I'm getting the same warning with the same (slightly newer) gems. My app is also running on Heroku. I wonder if there are any problems with my current Puma config: require 'fileutils'
require 'barnes'
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }
if ENV.fetch("RAILS_ENV") { "development" } == 'development'
worker_timeout 3600
end
workers ENV.fetch("WEB_CONCURRENCY") { 4 }
preload_app!
before_fork do
FileUtils.touch('/tmp/app-initialized')
ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
Barnes.start
end
on_worker_boot do
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end
plugin :tmp_restart Logs:
|
I get the same errors for |
Looks like this will be fixed in the next version of concurrent-ruby: ruby-concurrency/concurrent-ruby#868 |
Which has been released now: https://github.com/ruby-concurrency/concurrent-ruby/blob/v1.1.7/CHANGELOG.md#release-v117-6-august-2020, https://rubygems.org/gems/concurrent-ruby/versions I can confirm that the new concurrent-ruby version got rid of the warning where I saw it. |
I'm still seeing this with Ruby 2.6.6 and Rails 5.2.4.3:
Even though I have concurrent-ruby 1.1.7 in my Gemfile.lock? |
@h0jeZvgoxFepBQ2C That's coming from activerecord: https://github.com/rails/rails/blob/v5.2.4.3/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#L301 ...and I can see that you've found the related issues (rails/rails#37066, rails/rails#25259) on rails/rails :) I guess you could try open a new issue there, or maybe better, search/ask in their forum: https://discuss.rubyonrails.org/ |
I've been trying to get rid of this in my logs
WARNING: Detected 2 Thread(s) started in app boot:
.Here are the logs when I start puma:
(I edited this line to print the full backtrace.)
I edited this file:
/Users/myuser/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/atomic/ruby_thread_local_var.rb
:Output:
/Users/myuser/code/myapp/config/application.rb:7
is just:The problem seems to be that bootsnap requires(UPDATE: I was getting a lot of bootsnap lines in the backtrace so I turned it off, but the warning is still happening.)concurrent-ruby
when the app bootslib/concurrent-ruby/concurrent/atomic/ruby_thread_local_var.rb
is required, and this creates a new Thread immediately when the class is loaded:(
Thread.new
is called while the class is being defined, and not inside a method.)Does that mean that this
RubyThreadLocalVar
thread is not working properly inside the puma workers? I haven't noticed any problems with my app in production, but now I'm concerned that something isn't working properly.Thanks for your time!
The text was updated successfully, but these errors were encountered: