-
Notifications
You must be signed in to change notification settings - Fork 505
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
Using Phusion Passenger / Forking on Rails 5.2: NoMethodError (undefined method `any?' for nil:NilClass) #489
Comments
Hi, sorry! We moved to Knockoff briefly after I made this issue, but I still think the steps should work by using |
Seeing a similar issue but with Puma: NoMethodError (undefined method `any?' for nil:NilClass):
The connection_pool is getting discarded as part of the puma forking process, though I'm not smart enough to figure out if that's the root issue or if something else is going on:
puma has I was actually seeing an issue on Rails >= 5.0.1 < 5.2 where the db would run out of available connections, now I'm wondering if that's related. Had to revert back to Rails 5.0.0 for production for now. |
I'm experiencing the same issue as @whitmer with the latest version of the gem (0.10.1) and Rails 5.2, using Puma forked workers. I've written a terrible money-patch hack/workaround that seems to do the trick on most requests except some edge cases on non-preheated workers, in module Octopus
class Proxy
alias_method :safe_connection_without_fork_check, :safe_connection
def safe_connection_with_fork_check(connection_pool)
safe_connection_without_fork_check(connection_pool)
rescue NoMethodError
proxy_config.reinitialize_shards
retry
end
alias_method :safe_connection, :safe_connection_with_fork_check
def connected?
shards.any? { |_k, v| v.connected? }
rescue NoMethodError
proxy_config.reinitialize_shards
retry
end
end
end |
@jhoareau I've been running with the Octopus work around you mentioned above and it was pretty good. But my Sidekiq worker nodes sometimes become unresponsive and out of memory. So I tried your Puma |
I guess you should replace the |
Similar issue with Unicorn on production environment: |
I am getting this error as well. We are using puma. I noticed that everything works in console ( |
I can say for sure that this error is directly related to mis-configured database connection handling in your puma / unicorn configuration... Be sure you are correctly disconnect in your before fork and also reconnecting correctly in your after fork. For example unicorn you need before fork:
after fork
|
While trying to deploy our fork we got another error message when deploying to Phusion Passenger.
This could easiliy be replicated locally by downloading and running Passenger Standalone
It seems to be related to this commit:
rails/rails@f32cff5#diff-7735c67f539e7d1e2908a4d5d8909c24R453
From what I can read from there it seems that it is no longer safe to use
ConnectionPool
after it has been discarded.The text was updated successfully, but these errors were encountered: