app/models/good_job/execution.rb in good_job-3.19.4 vs app/models/good_job/execution.rb in good_job-3.20.0

- old
+ new

@@ -254,16 +254,17 @@ # raised, if any (if the job raised, then the second array entry will be # +nil+). If there were no jobs to execute, returns +nil+. def self.perform_with_advisory_lock(parsed_queues: nil, queue_select_limit: nil) execution = nil result = nil - unfinished.dequeueing_ordered(parsed_queues).only_scheduled.limit(1).with_advisory_lock(unlock_session: true, select_limit: queue_select_limit) do |executions| + unfinished.dequeueing_ordered(parsed_queues).only_scheduled.limit(1).with_advisory_lock(select_limit: queue_select_limit) do |executions| execution = executions.first break if execution.blank? unless execution.executable? result = ExecutionResult.new(value: nil, unexecutable: true) + execution = nil break end yield(execution) if block_given? result = execution.perform @@ -489,10 +490,12 @@ end # Tests whether this job is safe to be executed by this thread. # @return [Boolean] def executable? - self.class.unscoped.unfinished.owns_advisory_locked.exists?(id: id) + reload.finished_at.blank? + rescue ActiveRecord::RecordNotFound + false end def make_discrete self.is_discrete = true self.id = active_job_id