application_job.rb 1.1 KB

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ApplicationJob < ActiveJob::Base
  3. include ApplicationJob::HasDelayedJobMonitoringCompatibilty
  4. include ApplicationJob::HasQueuingPriority
  5. include ApplicationJob::HasCustomLogging
  6. discard_on HasActiveJobLock::LockKeyNotGeneratable
  7. # Rails 7.2 changed how background jobs are handled inside ActiveRecord transaction.
  8. # Turns out some jobs are still enqueued within transaction which is a bad practice.
  9. # For now, this reverts to pre-7.2 behavior.
  10. # Jobs enqueued inside transaction should be moved to post-transaction callbacks in the future.
  11. self.enqueue_after_transaction_commit = :never
  12. ActiveJob::LogSubscriber.detach_from :active_job
  13. # See config/initializers/delayed_jobs_timeout_per_job.rb for details.
  14. def self.max_run_time
  15. 4.hours
  16. end
  17. # Automatically retry jobs that encountered a deadlock
  18. # retry_on ActiveRecord::Deadlocked
  19. # Most jobs are safe to ignore if the underlying records are no longer available
  20. # discard_on ActiveJob::DeserializationError
  21. end