Skip to content
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

Rails 5.2 + Puma doesn't work when Puma workers are enabled #511

Open
zainzafar opened this issue Jan 17, 2019 · 14 comments
Open

Rails 5.2 + Puma doesn't work when Puma workers are enabled #511

zainzafar opened this issue Jan 17, 2019 · 14 comments

Comments

@zainzafar
Copy link

zainzafar commented Jan 17, 2019

My environment:
Rails 5.2.0
Octopus: 0.10.1
Puma 3.12.0

undefined method `any?' for nil:NilClass

activerecord (5.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `block in connected?'
/Users/zain/.rbenv/versions/2.6.0/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
activerecord (5.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `connected?'
ar-octopus (0.10.1) lib/octopus/proxy.rb:73:in `safe_connection'
ar-octopus (0.10.1) lib/octopus/proxy.rb:80:in `select_connection'
ar-octopus (0.10.1) lib/octopus/proxy.rb:225:in `legacy_method_missing_logic'
ar-octopus (0.10.1) lib/octopus/proxy.rb:131:in `method_missing'
activerecord (5.2.0) lib/active_record/migration.rb:554:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.0) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.0) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/executor.rb:14:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
railties (5.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.0) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.0) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.0) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.0) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.0) lib/rails/rack/logger.rb:26:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/request_id.rb:27:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack (2.0.6) lib/rack/method_override.rb:22:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack (2.0.6) lib/rack/runtime.rb:22:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
activesupport (5.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/executor.rb:14:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
actionpack (5.2.0) lib/action_dispatch/middleware/static.rb:127:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
rack-cors (1.0.2) lib/rack/cors.rb:97:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
railties (5.2.0) lib/rails/engine.rb:524:in `call'
newrelic_rpm (5.7.0.350) lib/new_relic/agent/instrumentation/middleware_tracing.rb:92:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'

error

@kjvarga
Copy link

kjvarga commented Jan 30, 2019

Seems to be a duplicate of #489

@knagode
Copy link

knagode commented Feb 18, 2019

@zainzafar did you figure this out? I have the same issue ...

@zainzafar
Copy link
Author

@knagode nop.. I stuck to Rails 5.1.x for now. Rails 6 has native support for multiple databases.

@knagode
Copy link

knagode commented Feb 21, 2019

@zainzafar After I added (config/puma.rb) ...

on_worker_boot do
  ActiveRecord::Base.establish_connection
  ActiveRecord::Base.connection.initialize_shards(Octopus.config
end

Octopus started working but I only can use it on dynos - I still have issues on worker dynos or rails console.

@knagode
Copy link

knagode commented Feb 28, 2019

@zainzafar how do you use octopus in gemfile? gem 'ar-octopus'? Or do you load specific version? Which?

@zainzafar
Copy link
Author

I did gem ar-octopus and made sure that I had the latest version in Gemfile.lock

@thiagopradi
Copy link
Owner

HI @zainzafar,

I haven't used Octopus + Puma yet. I'll try to reproduce your error locally to see if I can fix it.

Thiago

@zainzafar
Copy link
Author

Thanks @thiagopradi. This is the only gem that's preventing us to upgrade to Rails 5.2. Would love a fix to this.

@redox
Copy link

redox commented Jul 26, 2019

@thiagopradi looks like there is a number of issues opened related to this; any chance you could help?

@zainzafar
Copy link
Author

Any update on this @thiagopradi?

@stuartchaney
Copy link

@zainzafar - did you have any luck with this?

@jnarowski
Copy link

Still running into issues with this. Tried using the branch from master as well as kevinjcoleman's branch, but having no luck. Anyone else figure this out?

gem 'ar-octopus', git: 'https://github.com/kevinjcoleman/octopus.git', branch: 'feature/updating-octopus-versions'

We're using Puma and Rails 5.2.8.1

@jnarowski
Copy link

Don't want to speak too soon, but I might have fixed it with this:

on_worker_boot do
  if defined?(ActiveRecord::Base)
    ActiveRecord::Base.establish_connection
    ActiveRecord::Base.connection.initialize_shards(Octopus.config) if Octopus.enabled?
  end
end

@Adesoji1
Copy link

Can you upgrade your rails to version 7?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants