diff --git a/app/models/solid_queue/claimed_execution.rb b/app/models/solid_queue/claimed_execution.rb index ba469a3e..c2b13909 100644 --- a/app/models/solid_queue/claimed_execution.rb +++ b/app/models/solid_queue/claimed_execution.rb @@ -36,10 +36,10 @@ def release_all end end - def fail_all_with(error, reraise:) + def fail_all_with(error) SolidQueue.instrument(:fail_many_claimed) do |payload| includes(:job).tap do |executions| - executions.each { |execution| execution.failed_with(error, reraise: reraise) } + executions.each { |execution| execution.failed_with(error) } payload[:process_ids] = executions.map(&:process_id).uniq payload[:job_ids] = executions.map(&:job_id).uniq @@ -63,7 +63,8 @@ def perform if result.success? finished else - failed_with(result.error, reraise: true) + failed_with(result.error) + raise result.error end ensure job.unblock_next_blocked_job @@ -82,12 +83,11 @@ def discard raise UndiscardableError, "Can't discard a job in progress" end - def failed_with(error, reraise:) + def failed_with(error) transaction do job.failed_with(error) destroy! end - raise error if reraise end private diff --git a/app/models/solid_queue/process/executor.rb b/app/models/solid_queue/process/executor.rb index 23c41911..8dcd12aa 100644 --- a/app/models/solid_queue/process/executor.rb +++ b/app/models/solid_queue/process/executor.rb @@ -11,9 +11,9 @@ module Executor after_destroy :release_all_claimed_executions end - def fail_all_claimed_executions_with(error, reraise:) + def fail_all_claimed_executions_with(error) if claims_executions? - claimed_executions.fail_all_with(error, reraise: reraise) + claimed_executions.fail_all_with(error) end end diff --git a/app/models/solid_queue/process/prunable.rb b/app/models/solid_queue/process/prunable.rb index f116138e..85341d1d 100644 --- a/app/models/solid_queue/process/prunable.rb +++ b/app/models/solid_queue/process/prunable.rb @@ -23,7 +23,7 @@ def prune(excluding: nil) def prune error = Processes::ProcessPrunedError.new(last_heartbeat_at) - fail_all_claimed_executions_with(error, reraise: false) + fail_all_claimed_executions_with(error) deregister(pruned: true) end diff --git a/lib/solid_queue/supervisor.rb b/lib/solid_queue/supervisor.rb index 511886d4..9ef736e4 100644 --- a/lib/solid_queue/supervisor.rb +++ b/lib/solid_queue/supervisor.rb @@ -173,7 +173,7 @@ def replace_fork(pid, status) def handle_claimed_jobs_by(terminated_fork, status) if registered_process = process.supervisees.find_by(name: terminated_fork.name) error = Processes::ProcessExitError.new(status) - registered_process.fail_all_claimed_executions_with(error, reraise: false) + registered_process.fail_all_claimed_executions_with(error) end end diff --git a/lib/solid_queue/supervisor/maintenance.rb b/lib/solid_queue/supervisor/maintenance.rb index 3ce8fa53..1b6b5204 100644 --- a/lib/solid_queue/supervisor/maintenance.rb +++ b/lib/solid_queue/supervisor/maintenance.rb @@ -29,8 +29,7 @@ def prune_dead_processes def fail_orphaned_executions wrap_in_app_executor do - ClaimedExecution.orphaned. - fail_all_with(Processes::ProcessMissingError.new, reraise: false) + ClaimedExecution.orphaned.fail_all_with(Processes::ProcessMissingError.new) end end end diff --git a/test/models/solid_queue/claimed_execution_test.rb b/test/models/solid_queue/claimed_execution_test.rb index 04d5cacb..4e99fd04 100644 --- a/test/models/solid_queue/claimed_execution_test.rb +++ b/test/models/solid_queue/claimed_execution_test.rb @@ -67,7 +67,7 @@ class SolidQueue::ClaimedExecutionTest < ActiveSupport::TestCase job = claimed_execution.job assert_difference -> { SolidQueue::ClaimedExecution.count } => -1, -> { SolidQueue::FailedExecution.count } => 1 do - claimed_execution.failed_with(RuntimeError.new, reraise: false) + claimed_execution.failed_with(RuntimeError.new) end assert job.reload.failed?