Skip to content

Commit

Permalink
Merge pull request opf#15603 from opf/bug/ensure_discard_on_concurren…
Browse files Browse the repository at this point in the history
…cy_error

Makes sure jobs are eventually discarded when concurrency happens
  • Loading branch information
mereghost authored May 27, 2024
2 parents 62d0543 + 8c33cb5 commit 9b09a13
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/workers/mails/reminder_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@

class Mails::ReminderJob < Mails::DeliverJob
include ::Notifications::WithMarkedNotifications
include GoodJob::ActiveJobExtensions::Concurrency

good_job_control_concurrency_with(
total_limit: 1,
key: -> { "#{self.class.name}-#{arguments.last}" }
)

private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@

module Notifications
class CreateDateAlertsNotificationsJob < ApplicationJob
include GoodJob::ActiveJobExtensions::Concurrency

good_job_control_concurrency_with(
total_limit: 1,
key: -> { "#{self.class.name}-#{arguments.last}" }
)

def perform(user)
return unless EnterpriseToken.allows_to?(:date_alerts)

Expand Down
4 changes: 4 additions & 0 deletions app/workers/work_packages/progress/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ class WorkPackages::Progress::Job < ApplicationJob
perform_limit: 1,
key: -> { "WorkPackagesProgressJob" }
)

retry_on GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError,
wait: 5.minutes,
attempts: :unlimited
end
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class HealthStatusMailerJob < ApplicationJob
key: -> { "#{self.class.name}-#{arguments.last[:storage].id}" }
)

retry_on GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError,
wait: 5.minutes,
attempts: 3

discard_on ActiveJob::DeserializationError

def perform(storage:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class ManageStorageIntegrationsJob < ApplicationJob
enqueue_limit: 1,
perform_limit: 1
)

retry_on GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError,
wait: 5.minutes,
attempts: 3

SINGLE_THREAD_DEBOUNCE_TIME = 4.seconds.freeze
KEY = :manage_nextcloud_integration_job_debounce_happened_at
CRON_JOB_KEY = :"Storages::ManageStorageIntegrationsJob"
Expand Down

0 comments on commit 9b09a13

Please sign in to comment.