workless
workless copied to clipboard
failed_at is not in some delayed_job documents (mongoid)
Reading through the source of Workless, you check for failed_at attribute of the backend table:
if Rails.version >= "3.0.0"
Delayed::Job.where(:failed_at => nil)
else
Delayed::Job.all(:conditions => { :failed_at => nil })
end
But unfortunately when we're using the delayed_job_mongoid gem (which is where I think the problem is ultimately) we don't get this field. Here is an example document from my db:
{
"_id": {
"$oid": "54f092fa0bc40e34ff000004"
},
"priority": 0,
"attempts": 0,
"handler": "--- !ruby/struct:AlertTechBySMSJob\ntid: !ruby/object:Moped::BSON::ObjectId\n raw_data: !binary |-\n UgRkwNF5jQACAAB2\njid: !ruby/object:Moped::BSON::ObjectId\n raw_data: !binary |-\n VPCS+gvEDjT/AAAC\n",
"queue": "default",
"run_at": {
"$date": "2015-02-27T15:53:30.307Z"
},
"updated_at": {
"$date": "2015-02-27T15:53:30.307Z"
},
"created_at": {
"$date": "2015-02-27T15:53:30.307Z"
}
}
Therefore there are always no jobs return - so workless never fires.
I'm submitting the issue for documentation to others who might be searching, as well as to alert the team to consider alternative attributes to pivot on.
Because Workless limits attempts to 3, I think it might be better to pivot on this field.