nesquena / backburner

Simple and reliable beanstalkd job queue for ruby
http://nesquena.github.com/backburner
MIT License
430 stars 70 forks source link

Wrong number of arguments for ActiveRecord instance #136

Closed activestylus closed 7 years ago

activestylus commented 7 years ago

Why is it when I pass one AR instance into the perform method, it is interpreted as multiple arguments? In this case it's 9 args, which is based on the fact that this particular model has 9 attributes. Do I need to serialize the object somehow?

Backburner::Worker.enqueue(PostStatusUpdateJob, Post.last, :delay => 10.seconds)
[2016-12-10T17:00:38.430101 #14168] ERROR -- : Exception ArgumentError -> wrong number of arguments (given 9, expected 1)
   app/jobs/post_status_update_job.rb:8:in `perform'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/job.rb:54:in `block (2 levels) in process'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/job.rb:94:in `block in timeout_job_after'
   /Users/home/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
   /Users/home/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:33:in `block in catch'
   /Users/home/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:33:in `catch'
   /Users/home/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:33:in `catch'
   /Users/home/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:106:in `timeout'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/job.rb:94:in `timeout_job_after'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/job.rb:54:in `block in process'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/hooks.rb:28:in `block in around_hook_events'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/hooks.rb:37:in `around_hook_events'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/job.rb:48:in `process'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/worker.rb:136:in `work_one_job'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/workers/simple.rb:25:in `block in start'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/workers/simple.rb:25:in `loop'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/workers/simple.rb:25:in `start'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/worker.rb:59:in `start'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner.rb:40:in `work'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/cli.rb:23:in `block in start'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/dante-0.2.0/lib/dante/runner.rb:123:in `start'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/dante-0.2.0/lib/dante/runner.rb:74:in `execute'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/lib/backburner/cli.rb:20:in `start'
   /Users/home/.rvm/gems/ruby-2.3.1/gems/backburner-1.3.1/bin/backburner:7:in `<top (required)>'
   /Users/home/.rvm/gems/ruby-2.3.1/bin/backburner:22:in `load'
   /Users/home/.rvm/gems/ruby-2.3.1/bin/backburner:22:in `<main>'
   /Users/home/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
   /Users/home/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
I, [2016-12-10T17:00:38.431794 #14168]  INFO -- : Finished PostStatusUpdateJob in 3ms failed: attempt 4 of 4, burying
wrong number of arguments (given 9, expected 1)
activestylus commented 7 years ago

I've managed to work around this simply by passing an id to the perform method and doing all the querying from there