In my app, delayed jobs isn't running automatically on my server anymore. It used to..
When I manually ssh in, and perform rake jobs:work
I return this :
*** Starting job worker host:ip-(censored) pid:21458
* [Worker(host:ip-(censored) pid:21458)] acquired lock on PhotoJob
* [JOB] host:ip-(censored) pid:21458 failed with ActiveRecord::RecordNotFound: Couldn't find Photo with ID=9237 - 4 failed attempts
This returns roughly 20 times over for what I think is several jobs. Then I get a few of these:
* [Worker(host:ip-(censored) pid:21458)] failed to acquire exclusive lock for PhotoJob
And then finally one of these :
12 jobs processed at 73.6807 j/s, 12 failed ...
Any ideas what I should be mulling over? Thanks so much!
Edit :
Here is the photo controller that calls delayed jobs:
def update
@gallery = @organization.media.find_by_media_id(params[:gallery_id]).media
@photo = @gallery.photos.find(params[:id])
if @photo.update_attributes(params[:photo])
@photo.update_attribute(:processing, true)
logger.info "HERE IS PROCESSING #{@photo.processing}"
Delayed::Job.enqueue PhotoJob.new(@photo.id)
respond_to do |for开发者_开发问答mat|
format.html do
if params[:captions_screen] == 'true'
logger.info "WE ARE GOING TO DO NOTHING AT ALL"
render :text => ''
else
redirect_to organization_media_url(@organization)
end
end
format.js { redirect_to organization_media_url(@organization) }
end
else
render :action => 'edit'
end
end
Open your scripts/console and try to Photo.find(9237). You will probably get the same error. This means something/someone is calling controller action for unexistent record. You can avoid this by using find_by_id(params[:id]) which will return nil if there is no record with given id. Also add one more condition in your if statement
if @photo.present? && @photo.update_attributes(params[:photo])
Many many thanks to Tadas Tamosauskas on helping out, but after some research, I found that the problem is actually with delayed_jobs. What happened was when I deployed to a cluster server, the server overwrote my recipes on my ey-cloud for delayed_jobs to initialize. So delayed jobs never booted up. The jobs never ran. Updated the recipe, redeployed, everything is hunky dory.
精彩评论