resque-lock icon indicating copy to clipboard operation
resque-lock copied to clipboard

locks acquired but job never en-queued?

Open mcfiredrill opened this issue 11 years ago • 3 comments

I see this strange behavior occasionally, but often enough to want to find a fix. I'll en-queue some jobs. I can see the keys for the locks in the redis cli, but the jobs never seem to run. I don't see them ever appear in their queue or in the history (I use the resque-history plugin as well). Has anyone else ever seen any similar behavior?

mcfiredrill avatar Mar 18 '13 16:03 mcfiredrill

Are you raising Resque::Job::DontPerform in any of your before_perform hooks?

I am having a similar issue and I think this is the cause.

sdeframond avatar Jul 15 '13 09:07 sdeframond

I finally used this workaround that seems to work fine for my case. Instead of raising directly Resque::Job::DontPerform I call:

class MyJob
  extend Resque::Plugins::Lock

  def self.raise_dont_perform(*args)
    # Release the lock put by Resque::Plugins::Lock's before_perform hook.
    # We need to do that because else we never enter the around_perform
    # hook that removes the lock.
    Resque.redis.del(lock(*args))

    raise Resque::Job::DontPerform
  end
end

sdeframond avatar Jul 15 '13 10:07 sdeframond

Sorry a little late to the game here but if you run into this check if you have any other locking plugins like Resque Loner (which for example has a infinite TTL by default so if your process dies midway e.g. DirtyExit it will just stay locked). So you will see this lock expires then reissues but never enqueues.

f3z0 avatar Dec 03 '20 17:12 f3z0