application_job.rb 704 B

1234567891011121314151617181920
  1. class ApplicationJob < ActiveJob::Base
  2. # Automatically retry jobs that encountered a deadlock
  3. # retry_on ActiveRecord::Deadlocked
  4. # Most jobs are safe to ignore if the underlying records are no longer available
  5. # discard_on ActiveJob::DeserializationError
  6. # We (currently) rely on Delayed::Job#attempts to check for stuck backends
  7. # e.g. in the MonitoringController.
  8. # This is a workaround to sync ActiveJob#executions to Delayed::Job#attempts
  9. # until we resolve this dependency.
  10. around_enqueue do |job, block|
  11. block.call.tap do |delayed_job|
  12. # skip test adapter
  13. break if delayed_job.is_a?(Array)
  14. delayed_job.update!(attempts: job.executions)
  15. end
  16. end
  17. end