diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb')
-rw-r--r-- | lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb b/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb index 79ac853ea0c..4cf540ce3b8 100644 --- a/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb +++ b/lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb @@ -19,6 +19,7 @@ module Gitlab class DuplicateJob DUPLICATE_KEY_TTL = 6.hours DEFAULT_STRATEGY = :until_executing + STRATEGY_NONE = :none attr_reader :existing_jid @@ -51,6 +52,8 @@ module Gitlab end end + job['idempotency_key'] = idempotency_key + self.existing_jid = read_jid.value end @@ -100,6 +103,7 @@ module Gitlab def strategy return DEFAULT_STRATEGY unless worker_klass return DEFAULT_STRATEGY unless worker_klass.respond_to?(:idempotent?) + return STRATEGY_NONE unless worker_klass.deduplication_enabled? worker_klass.get_deduplicate_strategy end @@ -117,7 +121,7 @@ module Gitlab end def idempotency_key - @idempotency_key ||= "#{namespace}:#{idempotency_hash}" + @idempotency_key ||= job['idempotency_key'] || "#{namespace}:#{idempotency_hash}" end def idempotency_hash @@ -129,6 +133,10 @@ module Gitlab end def idempotency_string + # TODO: dump the argument's JSON using `Sidekiq.dump_json` instead + # this should be done in the next release so all jobs are written + # with their idempotency key. + # see https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1090 "#{worker_class_name}:#{arguments.join('-')}" end end |