1

I am using delayed_job gem for sending emails in my rails app. delayed_job was working well but from last 5 days, it is not working and throwing following error in delayed_job.log file.

2011-10-09T01:53:04+0530: [Worker(delayed_job host:backupserver pid:23953)] Syck::DomainType#private_group_join_request failed with NoMethodError: undefined method private_group_join_request' for # - 11 failed attempts
2011-10-09T01:53:04+0530: [Worker(delayed_job host:backupserver pid:23953)] 1 jobs processed at 1.4503 j/s, 1 failed ...
2011-10-09T01:54:40+0530: [Worker(delayed_job host:backupserver pid:23953)] Syck::DomainType#contact_us_email failed with NoMethodError: undefined method contact_us_email for # - 11 failed attempts
2011-10-09T01:54:40+0530: [Worker(delayed_job host:backupserver pid:23953)] 1 jobs processed at 4.3384 j/s, 1 failed ...

Following is one of the example how I am calling delayed job for sending email.

UserMailer.delay(:run_at => 10.seconds.from_now).contact_us_email(self)

I am starting delayed job with

RAILS_ENV=production script/delayed_job start

It is working correctly in development as well as production environment on my local machine.

Environment Which I am using in Rails App.

  • Rails 3.0.8
  • Ruby 1.9.2 in Linux(Ubuntu)
  • rake 0.9.2
  • delayed_job 2.1.4

This is same as Undefined Method Error when creating delayed_job workers with script/delay_job

But solution is not working for me.

Community
  • 1
  • 1
Kalpesh Fulpagare
  • 1,309
  • 10
  • 18
  • The "undefined method foo for #" is odd -- usually that sort of things is saying undefined method foo for nil, and then the problem is that the function is being called on a nil object. Do you have any idea what the "#" is referring to in your environment? – John Bachir Nov 09 '11 at 05:20
  • I found the reason why the delayed job was failing. As per given in http://stackoverflow.com/questions/6766431/undefined-method-error-when-creating-delayed-job-workers-with-script-delay-job the reason for failing was libyaml package. Package was installed on Server but is not installed on my local machine. Now I have installed the same package on my local machine, and it is giving me the same error. This error is coming at the time of deserialisation of data from database. – Kalpesh Fulpagare Nov 10 '11 at 06:00
  • Kaplesh: you might as well answer your own question so it is shown as answered, and other people would benefit from seeing how you fixed it. – fearless_fool Jul 05 '12 at 17:45

4 Answers4

5

I figured it out. It was due to package "libyaml" package, which was not present on my local system but was installed on server.

Kalpesh Fulpagare
  • 1,309
  • 10
  • 18
0

Is it possible that YAML (or Syck) running in the worker process doesn't know about the method in question? Take a look at:

https://github.com/collectiveidea/delayed_job/wiki/Common-problems#wiki-jobs_are_silently_removed_from_the_database

... the relevant part is:

One common cause of deserialization errors is that the YAML references a class not known to the worker. If this is the case, you can add

# file: config/initializers/custom.rb
require 'my_custom_class'

which will force my_custom_class to be loaded when the worker starts.

fearless_fool
  • 33,645
  • 23
  • 135
  • 217
  • What would this look like? 'required "User"'? And, that would load the User model? – hellion Nov 01 '14 at 23:04
  • @hellion: close. Try `require 'user'` -- of course, this depends upon your path being set up properly and such. I don't know enough about your environment to give you a complete answer. – fearless_fool Nov 02 '14 at 05:38
0

I had to restart my unicorns on the production server, by hand because for some reason cap deploy was not doing it for me.

So what I had to do was:

sudo /etc/init.d/unicorn_myapp stop
sudo /etc/init.d/unicorn_myapp start

But unicorn wasn't able to start, so I had to

sudo rm /tmp/unicorn.my_app.sock

And

sudo /etc/init.d/unicorn_myapp start
golfadas
  • 5,351
  • 3
  • 32
  • 39
0

Is it possible that you didn't stop and start your delayed_job worker when you deployed some new code? If a worker that was running before the deploy is trying to run new methods, it will fail.

John Bachir
  • 22,495
  • 29
  • 154
  • 227