app/models/good_job/execution.rb in good_job-3.15.10 vs app/models/good_job/execution.rb in good_job-3.15.11
- old
+ new
@@ -312,10 +312,12 @@
if retried
if current_execution.discrete?
execution = current_execution
execution.assign_attributes(enqueue_args(active_job, { scheduled_at: scheduled_at }))
execution.scheduled_at ||= Time.current
+ # TODO: these values ideally shouldn't be persisted until the current_execution is finished
+ # which will require handling `retry_job` being called from outside the execution context.
execution.performed_at = nil
execution.finished_at = nil
else
execution = build_for_enqueue(active_job, { scheduled_at: scheduled_at })
end
@@ -333,11 +335,15 @@
end
instrument_payload[:execution] = execution
execution.save!
- CurrentThread.execution.retried_good_job_id = execution.id if retried && !CurrentThread.execution.discrete?
+ if retried
+ CurrentThread.execution_retried = true
+ CurrentThread.execution.retried_good_job_id = execution.id unless current_execution.discrete?
+ end
+
active_job.provider_job_id = execution.id
execution
end
end
@@ -400,12 +406,12 @@
handled_error ||= current_thread.error_on_retry || current_thread.error_on_discard
instrument_payload.merge!(
value: value,
handled_error: handled_error,
- retried: current_thread.error_on_retry.present?
+ retried: current_thread.execution_retried
)
- ExecutionResult.new(value: value, handled_error: handled_error, retried: current_thread.error_on_retry.present?)
+ ExecutionResult.new(value: value, handled_error: handled_error, retried: current_thread.execution_retried)
rescue StandardError => e
instrument_payload[:unhandled_error] = e
ExecutionResult.new(value: nil, unhandled_error: e)
end
end