Skip to content

Commit 8f5e42b

Browse files
committed
Toggle whether errors should be reraised
1 parent 4fb5b9c commit 8f5e42b

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

app/models/solid_queue/claimed_execution.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def release_all
3636
end
3737
end
3838

39-
def fail_all_with(error)
39+
def fail_all_with(error, reraise: true)
4040
SolidQueue.instrument(:fail_many_claimed) do |payload|
4141
includes(:job).tap do |executions|
42-
executions.each { |execution| execution.failed_with(error) }
42+
executions.each { |execution| execution.failed_with(error, reraise:) }
4343

4444
payload[:process_ids] = executions.map(&:process_id).uniq
4545
payload[:job_ids] = executions.map(&:job_id).uniq
@@ -82,12 +82,12 @@ def discard
8282
raise UndiscardableError, "Can't discard a job in progress"
8383
end
8484

85-
def failed_with(error)
85+
def failed_with(error, reraise: true)
8686
transaction do
8787
job.failed_with(error)
8888
destroy!
8989
end
90-
raise error
90+
raise error if reraise
9191
end
9292

9393
private

app/models/solid_queue/process/executor.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module Executor
1111
after_destroy :release_all_claimed_executions
1212
end
1313

14-
def fail_all_claimed_executions_with(error)
14+
def fail_all_claimed_executions_with(error, reraise: true)
1515
if claims_executions?
16-
claimed_executions.fail_all_with(error)
16+
claimed_executions.fail_all_with(error, reraise:)
1717
end
1818
end
1919

app/models/solid_queue/process/prunable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def prune(excluding: nil)
2323

2424
def prune
2525
error = Processes::ProcessPrunedError.new(last_heartbeat_at)
26-
fail_all_claimed_executions_with(error)
26+
fail_all_claimed_executions_with(error, reraise: false)
2727

2828
deregister(pruned: true)
2929
end

lib/solid_queue/supervisor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def replace_fork(pid, status)
173173
def handle_claimed_jobs_by(terminated_fork, status)
174174
if registered_process = process.supervisees.find_by(name: terminated_fork.name)
175175
error = Processes::ProcessExitError.new(status)
176-
registered_process.fail_all_claimed_executions_with(error)
176+
registered_process.fail_all_claimed_executions_with(error, reraise: false)
177177
end
178178
end
179179

lib/solid_queue/supervisor/maintenance.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def prune_dead_processes
2929

3030
def fail_orphaned_executions
3131
wrap_in_app_executor do
32-
ClaimedExecution.orphaned.fail_all_with(Processes::ProcessMissingError.new)
32+
ClaimedExecution.orphaned.
33+
fail_all_with(Processes::ProcessMissingError.new, reraise: false)
3334
end
3435
end
3536
end

0 commit comments

Comments
 (0)