collectiveidea/delayed_job_active_record

Use case for locked_by in the ready_to_run query

arunn opened this issue · 1 comments

arunn commented

Hello,

"((run_at <= ? AND (locked_at IS NULL OR locked_at < ?)) OR locked_by = ?) AND failed_at IS NULL",

What is the use case for checking the OR locked_by = ? clause? My understanding is that if a job hasn't run for max_run_time but due to some event the worker that locked the job is trying to reserve another job. Is that right? If so, what are the events when that can happen?

I tried checking the git commits where it was introduced. It was introduced in the first commit of the project. So, I'm not sure why it was added.

Please ask these kinds of questions on the mailing list or Stack Overflow.

This covers a worker that died for some reason. It still holds the lock and can resume the job when it is restarted.