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

Cron rake stats:generate fails #2053

Open
Senen opened this issue Sep 5, 2019 · 0 comments
Open

Cron rake stats:generate fails #2053

Senen opened this issue Sep 5, 2019 · 0 comments

Comments

@Senen
Copy link

Senen commented Sep 5, 2019

User Story

Cron service runs a task to refresh stats every 2 hours but stats regeneration is failing because an exception thrown by Poll::Stats total_web_white method.

It seems current code in trying to access a method of nil object so an exception is thrown.

The mentioned rake task is:

rake stats:generate

Why is this Needed?

To be able update polls stats every 2 hours.

Description

Type: Bug

Here is the exception thrown by cron service:

ake aborted!
NoMethodError: undefined method `title' for nil:NilClass
/aytomad/app/participa/participacion/releases/20190718153714/app/models/poll/stats.rb:49:in `total_web_white'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:184:in `block (3 levels) in stats_cache'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:113:in `block in fetch'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:371:in `block in instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.7.2/lib/active_support/notifications.rb:166:in `instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:371:in `instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:112:in `fetch'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/poll/stats.rb:133:in `stats_cache'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:184:in `block (2 levels) in stats_cache'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/poll/stats.rb:41:in `total_web_valid'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:184:in `block (3 levels) in stats_cache'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:113:in `block in fetch'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:371:in `block in instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.7.2/lib/active_support/notifications.rb:166:in `instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:371:in `instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:112:in `fetch'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/poll/stats.rb:133:in `stats_cache'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:184:in `block (2 levels) in stats_cache'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/poll/stats.rb:30:in `block (2 levels) in <class:Stats>'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:184:in `block (3 levels) in stats_cache'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:113:in `block in fetch'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:371:in `block in instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.7.2/lib/active_support/notifications.rb:166:in `instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:371:in `instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:112:in `fetch'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/poll/stats.rb:133:in `stats_cache'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:184:in `block (2 levels) in stats_cache'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/poll/stats.rb:21:in `total_participants'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:184:in `block (3 levels) in stats_cache'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:113:in `block in fetch'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:371:in `block in instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.7.2/lib/active_support/notifications.rb:166:in `instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:371:in `instrument'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/dalli-2.7.6/lib/active_support/cache/dalli_store.rb:112:in `fetch'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/poll/stats.rb:133:in `stats_cache'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:184:in `block (2 levels) in stats_cache'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:14:in `block in generate'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:14:in `each'
/aytomad/app/participa/participacion/releases/20190718153714/app/models/concerns/statisticable.rb:14:in `generate'
/aytomad/app/participa/participacion/releases/20190718153714/lib/tasks/stats.rake:12:in `block (3 levels) in <top (required)>'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7.2/lib/active_record/relation/batches.rb:59:in `block (2 levels) in find_each'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7.2/lib/active_record/relation/batches.rb:59:in `each'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7.2/lib/active_record/relation/batches.rb:59:in `block in find_each'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7.2/lib/active_record/relation/batches.rb:121:in `block in find_in_batches'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7.2/lib/active_record/relation/batches.rb:214:in `block in in_batches'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7.2/lib/active_record/relation/batches.rb:198:in `loop'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7.2/lib/active_record/relation/batches.rb:198:in `in_batches'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7.2/lib/active_record/relation/batches.rb:120:in `find_in_batches'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7.2/lib/active_record/relation/batches.rb:58:in `find_each'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.7.2/lib/active_record/querying.rb:9:in `find_each'
/aytomad/app/participa/participacion/releases/20190718153714/lib/tasks/stats.rake:11:in `block (2 levels) in <top (required)>'
/aytomad/app/participa/participacion/shared/bundle/ruby/2.3.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/cli/exec.rb:74:in `load'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/cli/exec.rb:74:in `kernel_load'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/cli/exec.rb:27:in `run'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/cli.rb:335:in `exec'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/cli.rb:20:in `dispatch'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/cli.rb:11:in `start'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/exe/bundle:32:in `block in <top (required)>'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/gems/bundler-1.14.3/exe/bundle:24:in `<top (required)>'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/bin/bundle:22:in `load'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/bin/bundle:22:in `<main>'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/bin/ruby_executable_hooks:15:in `eval'
/aytomad/app/participa/.rvm/gems/ruby-2.3.2/bin/ruby_executable_hooks:15:in `<main>'

Current Behavior

The rake task fails when invoked through cron system service so stats are not updated.

Expected Behavior

The rake task is executed successfully and stats are refreshed.

Steps to reproduce

Re-run rake task used to refresh stats:

RAILS_ENV=environment bundle exec rake -s stats:generate --silent

Definition of Done

Stats are refreshed when rake task is invoked through system cron service.

@Senen Senen changed the title Sitemap rake refresh task is failing Cron rake stats:generate fails Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant