Saving multiple objects in rails activerecord - ruby

I have a recurring job with Rails + Heroku scheduler.rake.
The problem is that it won't save them successfully when it has too many entries.
How can I change this code to make all save completed without error?
This method doesn't need to complete quickly since it will work in the fixed time in the morning, so I am ok to save it one by one with some delay.
(I am using Heroku web and worker each 1x, 25$/month)
Thanks!
*Edited with error logs 2017/02/08
class RecurringEntryJob < ActiveJob::Base
queue_as :default
def perform(*args)
# Get active recurring entries
recurring_entries = Recurring.where(deleted: false)
Rails.logger.info "Recurring_Entry_Called"
for recurring_entry in recurring_entries
Rails.logger.info "“Recurring_Entry Processing for - #{recurring_entry[:id]}"
# Get the current time with saved timezone
timezone = recurring_entry["timezone"]
current_time = Time.now.in_time_zone(timezone)
setDate = recurring_entry["date"]
# Check if daily is set
if setDate == 0 ||
# Checkc if weekday matches
setDate == current_time.wday + 1 ||
# Check if monthly date or end of month match
setDate == current_time.day + 7 || current_time.tomorrow.day == 1 && setDate == 36
Rails.logger.info "Recurring_Entry Day of the week check passed for - #{recurring_entry[:id]}"
# Save an entry at AM4:00
if current_time.hour == 4
Rails.logger.info "Recurring_Entry All cheks passed for - #{recurring_entry[:id]} - creating entry"
# Create entry
entry = Entry.new
entry.user = User.find(recurring_entry["user_id"])
entry.reason = Reason.find_by!(uuid: recurring_entry["reason_uuid"])
entry.account = Account.find_by!(uuid: recurring_entry["account_uuid"])
entry.uuid = SecureRandom.uuid
entry.memo = recurring_entry["memo"]
entry.date = current_time
entry.price = recurring_entry["price"]
entry.is_expense = recurring_entry["is_expense"]
entry.updated_mobile = current_time
entry.reason_uuid = recurring_entry["reason_uuid"]
entry.account_uuid = recurring_entry["account_uuid"]
entry.project_uuid = recurring_entry["project_uuid"]
entry.save!
end
end
end
end
end
Error logs
Feb 08 04:10:51 taxnote heroku/scheduler.5289: Starting process with command `bundle exec rake recurring_entry`
Feb 08 04:10:51 taxnote heroku/scheduler.5289: State changed from starting to up
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] Performing RecurringEntryJob from Inline(default)
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] Recurring_Entry_Called
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 102
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 88
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 89
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 92
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 93
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 94
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 95
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 96
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 98
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 97
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 99
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 103
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 104
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 105
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 106
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] Recurring_Entry Day of the week check passed for - 106
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] Recurring_Entry All cheks passed for - 106 - creating entry
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 107
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 108
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 109
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 110
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 111
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 112
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 113
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 115
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 114
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 87
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 138
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 117
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] “Recurring_Entry Processing for - 118
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] Recurring_Entry Day of the week check passed for - 118
Feb 08 04:10:57 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] Recurring_Entry All cheks passed for - 118 - creating entry
Feb 08 04:10:58 taxnote app/scheduler.5289: [ActiveJob] [RecurringEntryJob] [88810de1-fffb-4e16-b8f8-17712bc5b084] Performed RecurringEntryJob from Inline(default) in 260.25ms
Feb 08 04:10:58 taxnote app/scheduler.5289: rake aborted!
Feb 08 04:10:58 taxnote app/scheduler.5289: ActiveRecord::RecordNotFound: Couldn't find Account
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/core.rb:196:in `find_by!'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/app/jobs/recurring_entry_job.rb:42:in `block in perform'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/relation/delegation.rb:46:in `each'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/relation/delegation.rb:46:in `each'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/app/jobs/recurring_entry_job.rb:11:in `perform'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/execution.rb:32:in `block in perform_now'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:117:in `call'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:505:in `call'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:343:in `block (2 levels) in simple'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/i18n-0.7.0/lib/i18n.rb:257:in `with_locale'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/translation.rb:7:in `block (2 levels) in <module:Translation>'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:441:in `instance_exec'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:441:in `block in make_lambda'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:342:in `block in simple'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:497:in `block in around'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:505:in `call'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:343:in `block (2 levels) in simple'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/logging.rb:23:in `block (4 levels) in <module:Logging>'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:164:in `block in instrument'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:164:in `instrument'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/logging.rb:22:in `block (3 levels) in <module:Logging>'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/logging.rb:43:in `block in tag_logger'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:68:in `block in tagged'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:26:in `tagged'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:68:in `tagged'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/logging.rb:43:in `tag_logger'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/logging.rb:19:in `block (2 levels) in <module:Logging>'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:441:in `instance_exec'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:441:in `block in make_lambda'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:342:in `block in simple'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:497:in `block in around'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:505:in `call'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_perform_callbacks'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/execution.rb:31:in `perform_now'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/execution.rb:21:in `execute'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/queue_adapters/inline_adapter.rb:14:in `enqueue'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/enqueuing.rb:71:in `block in enqueue'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:117:in `call'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:505:in `call'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:343:in `block (2 levels) in simple'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/logging.rb:14:in `block (3 levels) in <module:Logging>'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/logging.rb:43:in `block in tag_logger'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:68:in `block in tagged'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:26:in `tagged'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:68:in `tagged'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/logging.rb:43:in `tag_logger'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/logging.rb:13:in `block (2 levels) in <module:Logging>'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:441:in `instance_exec'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:441:in `block in make_lambda'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:342:in `block in simple'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:497:in `block in around'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:505:in `call'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_enqueue_callbacks'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/enqueuing.rb:67:in `enqueue'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/enqueuing.rb:17:in `perform_later'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/lib/tasks/scheduler.rake:4:in `block in <top (required)>'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bugsnag-4.0.2/lib/bugsnag/rake.rb:12:in `execute_with_bugsnag'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `load'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:74:in `kernel_load'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli/exec.rb:27:in `run'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:332:in `exec'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:20:in `dispatch'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/cli.rb:11:in `start'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/exe/bundle:34:in `block in <top (required)>'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/vendor/bundle/ruby/2.3.0/gems/bundler-1.13.7/exe/bundle:26:in `<top (required)>'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/bin/bundle:3:in `load'
Feb 08 04:10:58 taxnote app/scheduler.5289: /app/bin/bundle:3:in `<main>'
Feb 08 04:10:58 taxnote app/scheduler.5289: Tasks: TOP => recurring_entry
Feb 08 04:10:58 taxnote app/scheduler.5289: (See full trace by running task with --trace)
Feb 08 04:10:58 taxnote heroku/scheduler.5289: State changed from up to complete
Feb 08 04:10:58 taxnote heroku/scheduler.5289: Process exited with status 1

What is the exact error you're seeing?
Without seeing the error you're getting, Rails is probably trying to instantiate all of the matching instances of Recurring, and this is taking more memory than you have available. An easy way to attempt to solve this problem is to use find_each rather than instantiating the full result set. This will load the matching records in batches (with a default of 1000 records, but you can configure this to suit.
Recurring.where(deleted: false).find_each do |recurring|
# work on recurring
end
As the error that is happening is when an Account record is not found, you could add some error handling as follows to allow for that.
Recurring.where(deleted: false).find_each do |recurring|
# work on recurring
rescue ActiveRecord::RecordNotFound => e
Rails.logger.error("Account not found: #{recurring.account_uuid}")
next
end

I could fix this issue by checking the error logs, it was because when account part was not founded it stopped the loop.
class RecurringEntryJob < ActiveJob::Base
queue_as :default
def perform(*args)
# Get active recurring entries
recurring_entries = Recurring.where(deleted: false)
Rails.logger.info "Recurring_Entry_Called"
for recurring_entry in recurring_entries
# Rails.logger.info "“Recurring_Entry Processing for - #{recurring_entry[:id]}"
# Get the current time with saved timezone
timezone = recurring_entry["timezone"]
current_time = Time.now.in_time_zone(timezone)
setDate = recurring_entry["date"]
# Check if daily is set
if setDate == 0 ||
# Checkc if weekday matches
setDate == current_time.wday + 1 ||
# Check if monthly date or end of month match
setDate == current_time.day + 7 || current_time.tomorrow.day == 1 && setDate == 36
# Rails.logger.info "Recurring_Entry date check passed for - #{recurring_entry[:id]}"
# Save an entry at AM4:00
if current_time.hour == 4
Rails.logger.info "Recurring_Entry time check passed for - #{recurring_entry[:id]} - creating entry"
# Create entry
entry = Entry.new
entry.user = User.find(recurring_entry["user_id"])
if entry.user.blank?
Rails.logger.info "User Blank for - #{recurring_entry[:id]}"
next
end
entry.reason = Reason.find_by(uuid: recurring_entry["reason_uuid"])
if entry.reason.blank?
Rails.logger.info "Reason Blank for - #{recurring_entry[:id]}"
next
end
entry.account = Account.find_by(uuid: recurring_entry["account_uuid"])
if entry.account.blank?
Rails.logger.info "Account Blank for - #{recurring_entry[:id]}"
next
end
entry.uuid = SecureRandom.uuid
entry.memo = recurring_entry["memo"]
entry.date = current_time
entry.price = recurring_entry["price"]
entry.is_expense = recurring_entry["is_expense"]
entry.updated_mobile = current_time
entry.reason_uuid = recurring_entry["reason_uuid"]
entry.account_uuid = recurring_entry["account_uuid"]
entry.project_uuid = recurring_entry["project_uuid"]
entry.save!
Rails.logger.info "Recurring_Entry Completed for - #{recurring_entry[:id]}"
end
end
end
end
end

Related

How to mix the useful auto generated ticks() whilst also specifying the lowest granulatrity you want the tick interval to go down to

I'm creating a time series graph using D3 and I want the x-axis ticks to go down no lower than 2 hours without creating too many ticks.
Take this example which builds my point:
var x = d3.scaleTime().domain([new Date(2020, 4, 8).setHours(8), new Date(2020, 4, 9)])
.range([0, 960]).ticks()
The ticks() automatically calculates the ticks as no count or time interval argument is given, with this result:
console.log(x) output:
0: Fri May 08 2020 08:00:00
1: Fri May 08 2020 09:00:00
2: Fri May 08 2020 10:00:00
3: Fri May 08 2020 11:00:00
4: Fri May 08 2020 12:00:00
5: Fri May 08 2020 13:00:00
6: Fri May 08 2020 14:00:00
7: Fri May 08 2020 15:00:00
8: Fri May 08 2020 16:00:00
9: Fri May 08 2020 17:00:00
10: Fri May 08 2020 18:00:00
11: Fri May 08 2020 19:00:00
12: Fri May 08 2020 20:00:00
13: Fri May 08 2020 21:00:00
14: Fri May 08 2020 22:00:00
15: Fri May 08 2020 23:00:00
16: Sat May 09 2020 00:00:00
The granularity of the time is too low here (1 hour). I know I can fix this by changing my code to:
var x = d3.scaleTime().domain([new Date(2020, 4, 8).setHours(8), new Date(2020, 4, 9)])
.range([0, 960]).ticks(d3.timeHour.every(2))
Which outputs:
0: Fri May 08 2020 08:00:00
1: Fri May 08 2020 10:00:00
2: Fri May 08 2020 12:00:00
3: Fri May 08 2020 14:00:00
4: Fri May 08 2020 16:00:00
5: Fri May 08 2020 18:00:00
6: Fri May 08 2020 20:00:00
7: Fri May 08 2020 22:00:00
8: Sat May 09 2020 00:00:00
Perfect. However the problem is if I always pass d3.timeHour.every(2) into the ticks function it gives me way too many ticks for every scenario. For example if the domain is two dates which are say 5 days apart, I will get 100 ticks, whereas if I just did ticks() for that example I would get a sensible amount of ticks.
Is there a way to tell d3 to use the auto generated ticks() for every case but at the same time don't go down to a lower time interval than 2 hours?

bundle install gives Bundler::Dsl::DSLError

bundle install is giving Bundler::Dsl::DSLError error
bundle install
/usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/shared_helpers.rb:120:in `rescue in filesystem_access': Bundler::Dsl::DSLError
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/shared_helpers.rb:118:in `filesystem_access'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler.rb:430:in `read_file'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/dsl.rb:46:in `eval_gemfile'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/plugin.rb:60:in `gemfile_install'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/cli/install.rb:60:in `run'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/cli.rb:235:in `block in install'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/settings.rb:143:in `temporary'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/cli.rb:234:in `install'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/cli.rb:27:in `dispatch'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/cli.rb:18:in `start'
from /usr/share/rvm/rubies/ruby-2.2.10/bin/bundle:30:in `block in <main>'
from /usr/share/rvm/rubies/ruby-2.2.10/lib/ruby/site_ruby/2.2.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
from /usr/share/rvm/rubies/ruby-2.2.10/bin/bundle:22:in `<main>'
from /home/kiprosh/.rvm/gems/ruby-2.2.10/bin/ruby_executable_hooks:24:in `eval'
from /home/kiprosh/.rvm/gems/ruby-2.2.10/bin/ruby_executable_hooks:24:in `<main>'
I am using Windows 10 machine with Ubuntu 18.04 LTS app
Any idea how to fix?
I am using Ubuntu 18.04 with WSL on windows. Sometimes I open the application directory with an editor on Windows. When doing so, the permissions are changing on the ubuntu side.
Traceback (most recent call last):
21: from /home/omfaer/.rbenv/versions/2.5.3/bin/bundle:23:in `<main>'
20: from /home/omfaer/.rbenv/versions/2.5.3/bin/bundle:23:in `load'
19: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
18: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
17: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
16: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
15: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
14: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
13: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
12: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
11: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
10: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli.rb:255:in `install'
9: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/settings.rb:124:in `temporary'
8: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli.rb:256:in `block in install'
7: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli/install.rb:61:in `run'
6: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/plugin.rb:76:in `gemfile_install'
5: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/settings.rb:124:in `temporary'
4: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/plugin.rb:81:in `block in gemfile_install'
3: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/dsl.rb:46:in `eval_gemfile'
2: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler.rb:534:in `read_file'
1: from /home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/shared_helpers.rb:102:in `filesystem_access'
/home/omfaer/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/shared_helpers.rb:105:in `rescue in filesystem_access': Bundler::Dsl::DSLError
The permissions of the Gemfile file have changed.
-rw-r--r-- 1 omfaer omfaer 691 May 28 2019 .gitignore
---------- 1 omfaer omfaer 1583 Feb 28 11:47 Gemfile
-rw-r--r-- 1 omfaer omfaer 185 May 28 2019 README.md
-rw-r--r-- 1 omfaer omfaer 227 May 28 2019 Rakefile
I fixed the permissions and the problem is resolved.
$ chmod 644 Gemfile
I hope this helps you.

Heroku - Ruby error loop

I have not made any changes to ruby files, just a few layout changes and am seeing the following errors in Papertrail on my server. I did some digging by can't seem to find an answer.
Also the same code base is running in a QA system with no errors. Both servers are on the same build, Cedar-14, with the only difference being that the Prod server has a worker Dyno and QA does not.
Feb 01 11:24:46 skincaremarketplace app/worker.1: Don't know how to build
task 'jobs:work'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:74:in `load'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/cli/exec.rb:27:in `run'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/cli.rb:360:in `exec'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/cli.rb:20:in `dispatch'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/cli.rb:10:in `start'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/exe/bundle:30:in `block in <top (required)>'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/vendor/bundle/ruby/2.2.0/gems/bundler-1.15.2/exe/bundle:22:in `<top (required)>'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/bin/bundle:3:in `load'
Feb 01 11:24:46 skincaremarketplace app/worker.1: /app/bin/bundle:3:in `<main>'
Feb 01 11:24:46 skincaremarketplace app/worker.1: (See full trace by running task with --trace)
Feb 01 11:24:46 skincaremarketplace heroku/worker.1: Process exited with status 1
Feb 01 11:40:45 skincaremarketplace heroku/worker.1: State changed from crashed to starting
Feb 01 11:40:52 skincaremarketplace heroku/worker.1: Starting process with command `bundle exec rake jobs:work`
Feb 01 11:40:52 skincaremarketplace heroku/worker.1: State changed from starting to up
Feb 01 11:41:02 skincaremarketplace heroku/worker.1: Process exited with status 1
Feb 01 11:41:02 skincaremarketplace heroku/worker.1: State changed from up to crashed
Feb 01 11:41:02 skincaremarketplace app/worker.1: rake aborted!
Your prod server worker dyno tries to run bundle exec rake jobs:work (check your Procfile). Looks like you don't have that task. It normally should be in lib/tasks/jobs.rake.
If you scale up your QA workers they'll be failing too.
After reviewing the configuration on Heroku, All of our other applications that follow the same pattern, do not use jobs:work, or have a jobs.rake file. The worker was turned on in error. The investigation did shed some light, so thank you Stan.

Passenger startup failure on Heroku Cache Control

I am receiving a startup error for two of my projects when deploying to Heroku. Both work fine locally, it seems like the worker startup of sidekiq causes problems for passenger. I don't really understand where the problem could come from and have checked my procfile, my sidekiq conf and other elements. Any input would be much appreciated.
Nov 03 01:25:15 zugone-production app/web.1: [ 2015-11-03 09:25:14.9294 67/7fd6fe14d700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /app: An error occured while starting up the preloader.
Nov 03 01:25:15 zugone-production app/web.1: Error ID: 1a5af3e4
Nov 03 01:25:15 zugone-production app/web.1: Error details saved to: /tmp/passenger-error-UjpmyP.html
Nov 03 01:25:15 zugone-production app/web.1: Message from application: /app/vendor/bundle/ruby/2.0.0/gems/heroku-deflater-0.6.1/lib/heroku-deflater/serve_zipped_assets.rb:15: syntax error, unexpected ':', expecting =>
Nov 03 01:25:15 zugone-production app/web.1: ...= { headers: { 'Cache-Control': cache_control } } if Rails::...
Nov 03 01:25:15 zugone-production app/web.1: ... ^ (SyntaxError)
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/heroku-deflater-0.6.1/lib/heroku-deflater/railtie.rb:3:in `<top (required)>'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/heroku-deflater-0.6.1/lib/heroku-deflater.rb:1:in `<top (required)>'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `require'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `each'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `block in require'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `each'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `require'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.9.7/lib/bundler.rb:134:in `require'
Nov 03 01:25:15 zugone-production app/web.1: /app/config/application.rb:9:in `<top (required)>'
Nov 03 01:25:15 zugone-production app/web.1: /app/config/environment.rb:2:in `require'
Nov 03 01:25:15 zugone-production app/web.1: /app/config/environment.rb:2:in `<top (required)>'
Nov 03 01:25:15 zugone-production app/web.1: config.ru:3:in `require'
Nov 03 01:25:15 zugone-production app/web.1: config.ru:3:in `block in <main>'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `instance_eval'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `initialize'
Nov 03 01:25:15 zugone-production app/web.1: config.ru:1:in `new'
Nov 03 01:25:15 zugone-production app/web.1: config.ru:1:in `<main>'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/passenger-5.0.21/src/helper-scripts/rack-preloader.rb:110:in `eval'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/passenger-5.0.21/src/helper-scripts/rack-preloader.rb:110:in `preload_app'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/passenger-5.0.21/src/helper-scripts/rack-preloader.rb:156:in `<module:App>'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/passenger-5.0.21/src/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
Nov 03 01:25:15 zugone-production app/web.1: /app/vendor/bundle/ruby/2.0.0/gems/passenger-5.0.21/src/helper-scripts/rack-preloader.rb:29:in `<main>'
Nov 03 01:25:15 zugone-production app/web.1: [ 2015-11-03 09:25:14.9793 67/7fd6dbfff700 age/Cor/Req/CheckoutSession.cpp:253 ]: [Client 3-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 1a5af3e4. Please see earlier logs for details about the error.
Nov 03 01:25:15 zugone-production app/web.1: [ 2015-11-03 09:25:14.9801 67/7fd6f6ffe700 age/Cor/Req/CheckoutSession.cpp:253 ]: [Client 1-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 1a5af3e4. Please see earlier logs for details about the error.
Nov 03 01:25:15 zugone-production app/web.1: [ 2015-11-03 09:25:14.9803 67/7fd6f5ffd700 age/Cor/Req/CheckoutSession.cpp:253 ]: [Client 2-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 1a5af3e4. Please see earlier logs for details about the error.
Nov 03 01:25:15 zugone-production app/web.1: [ 2015-11-03 09:25:14.9806 67/7fd6c3fff700 age/Cor/Req/CheckoutSession.cpp:253 ]: [Client 6-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 1a5af3e4. Please see earlier logs for details about the error.
Nov 03 01:25:15 zugone-production app/web.1: [ 2015-11-03 09:25:14.9807 67/7fd6c1ffd700 age/Cor/Req/CheckoutSession.cpp:253 ]: [Client 8-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 1a5af3e4. Please see earlier logs for details about the error.
Nov 03 01:25:15 zugone-production app/web.1: [ 2015-11-03 09:25:14.9809 67/7fd6c2ffe700 age/Cor/Req/CheckoutSession.cpp:253 ]: [Client 7-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 1a5af3e4. Please see earlier logs for details about the error.
Nov 03 01:25:15 zugone-production app/web.1: [ 2015-11-03 09:25:14.9811 67/7fd6daffe700 age/Cor/Req/CheckoutSession.cpp:253 ]: [Client 4-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 1a5af3e4. Please see earlier logs for details about the error.
Nov 03 01:25:15 zugone-production app/web.1: [ 2015-11-03 09:25:14.9812 67/7fd6d9ffd700 age/Cor/Req/CheckoutSession.cpp:253 ]: [Client 5-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 1a5af3e4. Please see earlier logs for details about the error.
Nov 03 01:25:16 zugone-production heroku/router: at=info method=GET path="/" host=www.zug-erstattung.de request_id=39412581-e55c-4e29-8730-c4c1694b660b fwd="172.21.225.211,130.238.98.89" dyno=web.1 connect=1ms service=5903ms status=500 bytes=2847
Nov 03 01:25:16 zugone-production app/worker.1: /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require': /app/vendor/bundle/ruby/2.0.0/gems/heroku-deflater-0.6.1/lib/heroku-deflater/serve_zipped_assets.rb:15: syntax error, unexpected ':', expecting => (SyntaxError)
Nov 03 01:25:16 zugone-production app/worker.1: ...= { headers: { 'Cache-Control': cache_control } } if Rails::...
Nov 03 01:25:16 zugone-production app/worker.1: ... ^
I had same problem as following 1 hour ago.
SyntaxError:
/app/vendor/bundle/ruby/2.1.0/gems/heroku-deflater-0.6.1/lib/heroku-deflater/serve_zipped_assets.rb:15:
syntax error, unexpected ':', expecting => ...= { headers: {
'Cache-Control': cache_control } } if Rails::...
It seems that heroku-deflater was updated 21 hours ago.
Though I don't know the reason this error is caused at all,
I was able to make my apps work well on Heroku by define heroku-deflater version on Gemfile like this.
■ Gemfile
gem 'heroku-deflater', '0.5.3 ', :group => :production
I would like to wait that heroku-deflater will be updated again.
Thank you!

Failing to catch Errno::ECONNRESET in Ruby code

In my Rails 3.1 project, deployed to Heroku, I have a rake task that generates a few hundred thousand small PNGs based on records in the database and uploads the results to S3 using fog, one file at a time. (Before I was using heroku, the task saved the files locally and everything worked fine.) When I run the task using heroku run:detached, it runs for a while, and uploads a bunch of files, but eventually fails with Connection reset by peer (Errno::ECONNRESET). What's weird about this is that I've modified the script to catch and retry that exception like so:
file_exists = false
retry_count = 10
begin
file_exists = directory.files.head(filekey)
rescue Errno::ECONNRESET => e
if retry_count > 0 then
logger.warning("Connection reset: #{e.inspect}")
retry_count -= 1
sleep(1)
retry
else
raise
end
end
According to the stack trace, file_exists = directory.files.head(filekey) is the line of my code that leads to the exception, so I feel like I'm missing something about Ruby exception handling. I'd love to know what I'm doing wrong, since I'm not 100% sure if this is a problem with my begin/rescue block, the way fog handles network errors, or what.
Here's the complete stack trace:
Nov 07 12:08:01 ... app/run.1: Connection reset by peer (Errno::ECONNRESET)
Nov 07 12:08:01 ... app/run.1: /app/vendor/ruby-1.8.7/lib/ruby/1.8/openssl/buffering.rb:36:in `sysread'
Nov 07 12:08:01 ... app/run.1: /app/vendor/ruby-1.8.7/lib/ruby/1.8/openssl/buffering.rb:36:in `fill_rbuff'
Nov 07 12:08:01 ... app/run.1: /app/vendor/ruby-1.8.7/lib/ruby/1.8/openssl/buffering.rb:68:in `read'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/excon-0.16.7/lib/excon/socket.rb:121:in `read'
Nov 07 12:08:01 ... app/run.1: /app/vendor/ruby-1.8.7/lib/ruby/1.8/timeout.rb:67:in `timeout'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/excon-0.16.7/lib/excon/socket.rb:120:in `read'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/excon-0.16.7/lib/excon/ssl_socket.rb:79:in `read'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/excon-0.16.7/lib/excon/response.rb:21:in `parse'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/excon-0.16.7/lib/excon/connection.rb:275:in `request_kernel'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/excon-0.16.7/lib/excon/connection.rb:103:in `request'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/fog-1.6.0/lib/fog/core/connection.rb:20:in `request'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/fog-1.6.0/lib/fog/aws/storage.rb:392:in `request'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/fog-1.6.0/lib/fog/aws/requests/storage/head_object.rb:53:in `head_object'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/fog-1.6.0/lib/fog/aws/models/storage/files.rb:98:in `head'
Nov 07 12:08:01 ... app/run.1: /app/lib/tasks/assets.rake:45
Nov 07 12:08:01 ... app/run.1: /app/lib/tasks/assets.rake:37:in `each'
Nov 07 12:08:01 ... app/run.1: /app/lib/tasks/assets.rake:37
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/activerecord-3.1.8/lib/active_record/relation/batches.rb:21:in `find_each'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/activerecord-3.1.8/lib/active_record/relation/batches.rb:21:in `each'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/activerecord-3.1.8/lib/active_record/relation/batches.rb:21:in `find_each'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/activerecord-3.1.8/lib/active_record/relation/batches.rb:69:in `find_in_batches'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/activerecord-3.1.8/lib/active_record/relation/batches.rb:20:in `find_each'
Nov 07 12:08:01 ... app/run.1: /app/lib/tasks/assets.rake:35
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
Nov 07 12:08:01 ... app/run.1: /app/vendor/ruby-1.8.7/lib/ruby/1.8/monitor.rb:242:in `synchronize'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/gems/rake-0.9.2.2/bin/rake:33
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/bin/rake:23:in `load'
Nov 07 12:08:01 ... app/run.1: /app/vendor/bundle/ruby/1.8/bin/rake:23
Nov 07 12:08:01 ... app/run.1: Tasks: TOP => ...:make_outlines
Nov 07 12:08:02 ... heroku/run.1: Process exited with status 1
Nov 07 12:08:02 ... heroku/run.1: State changed from up to complete
perhaps try like this:
begin
...
rescue Errno::ECONNRESET => e
...
rescue => e
...
end

Resources