2018-07-23 08:23:01 +00:00
|
|
|
class ApplicationJob < ActiveJob::Base
|
|
|
|
# Automatically retry jobs that encountered a deadlock
|
|
|
|
# retry_on ActiveRecord::Deadlocked
|
|
|
|
|
|
|
|
# Most jobs are safe to ignore if the underlying records are no longer available
|
|
|
|
# discard_on ActiveJob::DeserializationError
|
2019-01-02 20:53:29 +00:00
|
|
|
|
|
|
|
# We (currently) rely on Delayed::Job#attempts to check for stuck backends
|
|
|
|
# e.g. in the MonitoringController.
|
|
|
|
# This is a workaround to sync ActiveJob#executions to Delayed::Job#attempts
|
|
|
|
# until we resolve this dependency.
|
|
|
|
around_enqueue do |job, block|
|
|
|
|
block.call.tap do |delayed_job|
|
2019-01-15 12:21:04 +00:00
|
|
|
# skip test adapter
|
|
|
|
break if delayed_job.is_a?(Array)
|
|
|
|
|
2019-01-02 20:53:29 +00:00
|
|
|
delayed_job.update!(attempts: job.executions)
|
|
|
|
end
|
|
|
|
end
|
2018-07-23 08:23:01 +00:00
|
|
|
end
|