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

Resque jobs failing for missing AR connection on Rails 5.2 #33097

Closed
CodingAnarchy opened this issue Jun 8, 2018 · 3 comments
Closed

Resque jobs failing for missing AR connection on Rails 5.2 #33097

CodingAnarchy opened this issue Jun 8, 2018 · 3 comments
Labels

Comments

@CodingAnarchy
Copy link
Contributor

Steps to reproduce

Queue enough resque jobs that have to connect to the database, and this appears to occur sporadically. I haven't been able to nail down any precise cause. This seems to happen most often with ActiveStorage::PurgeJobs, but that could be just because they are common. It also happens with other Rails-specific and custom jobs alike.

Expected behavior

Jobs should be able to fetch the records they need to perform the job and continue without a problem in every case.

Actual behavior

About one job in a thousand results in this error:

undefined method `[]' for nil:NilClass
/srv/app/shared/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:389:in `active_connection?'
/srv/app/shared/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:36:in `enable_query_cache!'
/srv/app/shared/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/query_cache.rb:32:in `block in run'
/srv/app/shared/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/query_cache.rb:29:in `map'
/srv/app/shared/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/query_cache.rb:29:in `run'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/execution_wrapper.rb:27:in `before'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:426:in `block in make_lambda'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:605:in `catch'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:605:in `block in default_terminator'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:199:in `block in halting'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:513:in `block in invoke_before'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:513:in `each'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:513:in `invoke_before'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:131:in `run_callbacks'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/execution_wrapper.rb:110:in `run!'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/execution_wrapper.rb:72:in `block in run!'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/execution_wrapper.rb:69:in `tap'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/execution_wrapper.rb:69:in `run!'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/execution_wrapper.rb:85:in `wrap'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/reloader.rb:72:in `wrap'
/srv/app/shared/bundle/ruby/2.5.0/gems/activejob-5.2.0/lib/active_job/railtie.rb:27:in `block (3 levels) in <class:Railtie>'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:118:in `instance_exec'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/srv/app/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.0/lib/active_support/callbacks.rb:136:in `run_callbacks'
/srv/app/shared/bundle/ruby/2.5.0/gems/activejob-5.2.0/lib/active_job/execution.rb:22:in `execute'
/srv/app/shared/bundle/ruby/2.5.0/gems/activejob-5.2.0/lib/active_job/queue_adapters/resque_adapter.rb:47:in `perform'

Retrying the job manually seems to work.

System configuration

Rails version: 5.2.0

Ruby version: 2.5.1

@CodingAnarchy CodingAnarchy changed the title Rescue jobs failing for missing AR connection on Rails 5.2 Resque jobs failing for missing AR connection on Rails 5.2 Jun 8, 2018
@rafaelfranca
Copy link
Member

Can you please provide a sample application that reproduces the error?

@eugeneius
Copy link
Member

This looks like the same problem as #33022.

@rails-bot rails-bot bot added the stale label Sep 7, 2018
@rails-bot
Copy link

rails-bot bot commented Sep 7, 2018

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 5-2-stable branch or on master, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

@rails-bot rails-bot bot closed this as completed Sep 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants