collectiveidea/delayed_job_active_record — pull request #53 by eric88 (2013-04-16 01:09:02+00:00)
Title: Fix for issue where failed jobs running repeatedly

Ran into a bug today that can be reproduced like so:
1. Make a method in a class that simply raises an exception.
2. Queue said method multiple times within the same second with max_attempts = 1.
3. Start your worker.

The first job will be run repeatedly within the same second. This is because of the following code:
```ruby
count = ready_scope.limit(1).update_all(:locked_at => now, :locked_by => worker.name)
return nil if count == 0
self.where(:locked_at => now, :locked_by => worker.name).first
```
The second query will return the first job even though another job has been locked. Adding `:failed_at => nil` to the where() fixes this.