mperham / connection_pool

Generic connection pooling for Ruby
MIT License
1.63k stars 143 forks source link

crash after fork with 2.4.0 #174

Closed matt-domsch-sp closed 1 year ago

matt-domsch-sp commented 1 year ago

We are using a fork call in a custom sidekiq add-in from the startup handler to run some extra bit of functionality we need. sq_config.on(:startup) do @server_pid = fork do sa::Server.run! end With connection_pool 2.4.0, we're getting the below traceback when doing so which we had not seen before, and suspect it's due to the change in 2.4.0 to close threads. Error we see:

NoMethodError: undefined method[]' for nil:NilClass

stack = Thread.current[@key][net_http_args] ||= []
                            ^^^^^^^^^^^^^^^

` Backtrace:

/usr/local/bundle/gems/net-http-persistent-4.0.1/lib/net/http/persistent/pool.rb:14:incheckin' /usr/local/bundle/gems/connection_pool-2.4.0/lib/connection_pool.rb:56:in block in after_fork' /usr/local/bundle/gems/connection_pool-2.4.0/lib/connection_pool.rb:52:ineach' /usr/local/bundle/gems/connection_pool-2.4.0/lib/connection_pool.rb:52:in after_fork' /usr/local/bundle/gems/connection_pool-2.4.0/lib/connection_pool.rb:72:in_fork' /usr/local/bundle/gems/activesupport-7.0.4/lib/active_support/fork_tracker.rb:7:in _fork' /usr/local/bundle/gems/sidekiq_scaler-1.0.5/lib/sidekiq_scaler.rb:24:infork' /usr/local/bundle/gems/sidekiq_scaler-1.0.5/lib/sidekiq_scaler.rb:24:in block (3 levels) in start' ...

using sidekiq 6.4.2. We had not experienced this with connection_pool 2.3.0.

mperham commented 1 year ago

Dupe