lib/good_job/job.rb in good_job-1.13.2 vs lib/good_job/job.rb in good_job-1.99.0
- old
+ new
@@ -187,10 +187,16 @@
unfinished.priority_ordered.only_scheduled.limit(1).with_advisory_lock(unlock_session: true) do |good_jobs|
good_job = good_jobs.first
break if good_job.blank?
break :unlocked unless good_job&.executable?
- good_job.perform
+ begin
+ good_job.with_advisory_lock(key: "good_jobs-#{good_job.active_job_id}") do
+ good_job.perform
+ end
+ rescue RecordAlreadyAdvisoryLockedError => e
+ ExecutionResult.new(value: nil, handled_error: e)
+ end
end
end
# Fetches the scheduled execution time of the next eligible Job(s).
# @param after [DateTime]