Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Delayed::DeserializationError #50

Open
ajsharp opened this Issue · 5 comments

6 participants

@ajsharp

I get the following error when I try to build a project after deleting failed or hung builds. Not exactly sure what's happening here, but it seems like something is getting corrupted in DelayedJob. It would be nice to have some sort of "big red button" clear the job queue feature.

Delayed::DeserializationError (Delayed::DeserializationError):
  app/models/project.rb:142:in `remove_project_jobs_in_queue'
  app/models/project.rb:141:in `each'
  app/models/project.rb:141:in `remove_project_jobs_in_queue'
  app/models/project.rb:45:in `build!'
  app/models/project.rb:42:in `build!'
  app/controllers/projects_controller.rb:22:in `build'
@phallstrom

I have the same issue periodically. Running 'rake jobs:clear' works for me to clear it out...

rake jobs:clear # Clear the delayed_job queue.

@gorenje

Could be something to do with this comment collectiveidea/delayed_job#183 (comment) --> basically if delayed job tries to retrieve a job referencing an AR object and that object has been deleted, you don't get a ActiveRecord::RecordNotFound but a Delayed::DeserizalisationError --> https://github.com/collectiveidea/delayed_job/blob/b4a80598faf9e6399e2208c26a50b5c9ffa45afd/lib/delayed/serialization/active_record.rb (the head at time of writing)

@ypadlyak

I'm experiencing simular issue:

delayed_job's last_error contains:
{Job failed to load: undefined method keys' for nil:NilClass. Handler: "--- !ruby/object:Build \nattributes: \n project_id: 1\n commit: \n status: status_build_in_queue\n output: []\n\n created_at: &id001 2011-09-26 11:16:30.848965 Z\n updated_at: *id001\n build_dir: /home/ruby/dev/bigtuna/builds/snorkestopp/build_22_20110926111630\n started_at: \n scheduled_at: 2011-09-26 11:16:30.848918 Z\n author: \n email: \n committed_at: \n commit_message: \n finished_at: \n build_no: 22\n id: 34\n"
/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/backend/base.rb:81:in
rescue in payload_object'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/backend/base.rb:79:in payload_object'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/backend/base.rb:87:ininvoke_job'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:120:in block (2 levels) in run'\n/home/ruby/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/timeout.rb:58:intimeout'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:120:in block in run'\n/home/ruby/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:inrealtime'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:119:in run'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:177:inreserve_and_run_one_job'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:104:in block in work_off'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:103:intimes'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:103:in work_off'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:78:inblock (2 levels) in start'\n/home/ruby/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in realtime'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:77:inblock in start'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:74:in loop'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/worker.rb:74:instart'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/command.rb:104:in run'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/command.rb:83:inblock in run_process'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons/application.rb:249:in call'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons/application.rb:249:inblock in start_proc'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons/daemonize.rb:197:in call'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons/daemonize.rb:197:incall_as_daemon'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons/application.rb:253:in start_proc'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons/application.rb:293:instart'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons/controller.rb:70:in run'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons.rb:195:inblock in run_proc'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons/cmdline.rb:109:in call'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons/cmdline.rb:109:incatch_exceptions'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/daemons-1.1.4/lib/daemons.rb:194:in run_proc'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/command.rb:81:inrun_process'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/command.rb:75:in block in daemonize'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/command.rb:73:intimes'\n/home/ruby/.rvm/gems/ruby-1.9.2-p290@bigtuna/gems/delayed_job-2.1.4/lib/delayed/command.rb:73:in daemonize'\n./script/delayed_job:5:in

'

@tedgrubb

I use DJ to handle a lot of my after_creates and was running into similar issues. I wasn't able to find a way around it using the delay.do_the_job method, but am able to keep it from happening by passing the object id and doing an explicit AR find_by_id.

I created a generic AfterCreateJob class that I can use to handle all of my delayed after_create needs

Maybe there's a better way to handle it, but here's what I'm doing.

class SomeModel < ActiveRecord::Base
after_create :delay_after_create
def delay_after_create
Delayed::Job.enqueue(AfterCreateJob.new(self.id, SomeModel))
end
def after_create_job
job_to_run
another_job_to_run
rescue
return true
end

private

def job_to_run
end

def another_job_to_run
end

end

class AfterCreateJob < Struct.new(:id, :klass)
def perform
if obj = klass.find_by_id(id)
obj.after_create_job
end
true
rescue Exception => e
logger.error e.inspect
false
end

def logger
Delayed::Worker.logger
end

end

@Salzig

lazy "fix":

diff --git a/app/models/project.rb b/app/models/project.rb
index 0b6f7a1..deab679 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -174,7 +174,7 @@ class Project < ActiveRecord::Base
   def remove_project_jobs_in_queue
     jobs_to_destroy = []
     Delayed::Job.all.each do |job|
-      build = job.payload_object
+      build = job.payload_object rescue nil
       next unless build.is_a?(Build)
       if build.status = Build::STATUS_IN_QUEUE && build.project == self
         jobs_to_destroy << job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.