Skip to content

Commit b1b040b

Browse files
committed
Rescues around the execute.
This prevents the executor from crashing entirely when mosquito itself encounters an error during the execution setup/teardown. The most common case for this is when mosquito is running against a redis that has jobs it's unaware of, and it fails to deserialize the Job.
1 parent abdc026 commit b1b040b

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/mosquito/runners/executor.cr

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,18 @@ module Mosquito::Runners
120120
self.state = State::Working
121121
@work_unit = dequeue
122122
log.trace { "Dequeued #{job_run} from #{queue.name}" }
123-
execute
123+
124+
begin
125+
execute
126+
rescue e
127+
log.error { "Crashed executing #{job_run}: #{e.inspect}" }
128+
begin
129+
job_run.retry_or_banish queue
130+
rescue
131+
queue.banish job_run
132+
end
133+
end
134+
124135
log.trace { "Finished #{job_run} from #{queue.name}" }
125136

126137
if @decommissioned

0 commit comments

Comments
 (0)