diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /app/workers/concerns/application_worker.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/workers/concerns/application_worker.rb')
-rw-r--r-- | app/workers/concerns/application_worker.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/workers/concerns/application_worker.rb b/app/workers/concerns/application_worker.rb index 3cba1eb31c5..e158ae0c298 100644 --- a/app/workers/concerns/application_worker.rb +++ b/app/workers/concerns/application_worker.rb @@ -47,11 +47,36 @@ module ApplicationWorker end class_methods do + extend ::Gitlab::Utils::Override + def inherited(subclass) subclass.set_queue subclass.after_set_class_attribute { subclass.set_queue } end + override :validate_worker_attributes! + def validate_worker_attributes! + super + + # Since the delayed data_consistency will use sidekiq built in retry mechanism, it is required that this mechanism + # is not disabled. + if retry_disabled? && get_data_consistency == :delayed + raise ArgumentError, "Retry support cannot be disabled if data_consistency is set to :delayed" + end + end + + # Checks if sidekiq retry support is disabled + def retry_disabled? + get_sidekiq_options['retry'] == 0 || get_sidekiq_options['retry'] == false + end + + override :sidekiq_options + def sidekiq_options(opts = {}) + super.tap do + validate_worker_attributes! + end + end + def perform_async(*args) # Worker execution for workers with data_consistency set to :delayed or :sticky # will be delayed to give replication enough time to complete |