Commit 4c37bfdc authored by James Fargher's avatar James Fargher

Merge branch '341284-enable-idempotentcy-for-single-worker' into 'master'

Enable idempontency for UserRefreshOverUserRangeWorker"

See merge request gitlab-org/gitlab!70781
parents c13fe74c 9f02ba98
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
:urgency: :low :urgency: :low
:resource_boundary: :unknown :resource_boundary: :unknown
:weight: 1 :weight: 1
:idempotent: :idempotent: true
:tags: [] :tags: []
- :name: authorized_project_update:authorized_project_update_user_refresh_with_low_urgency - :name: authorized_project_update:authorized_project_update_user_refresh_with_low_urgency
:worker_name: AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker :worker_name: AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker
......
...@@ -19,11 +19,10 @@ module AuthorizedProjectUpdate ...@@ -19,11 +19,10 @@ module AuthorizedProjectUpdate
feature_category :authentication_and_authorization feature_category :authentication_and_authorization
urgency :low urgency :low
queue_namespace :authorized_project_update queue_namespace :authorized_project_update
# This job will not be deduplicated since it is marked with
# `data_consistency :delayed` and not `idempotent!`
# See https://gitlab.com/gitlab-org/gitlab/-/issues/325291
deduplicate :until_executing, including_scheduled: true deduplicate :until_executing, including_scheduled: true
data_consistency :delayed data_consistency :delayed
idempotent!
def perform(start_user_id, end_user_id) def perform(start_user_id, end_user_id)
User.where(id: start_user_id..end_user_id).find_each do |user| # rubocop: disable CodeReuse/ActiveRecord User.where(id: start_user_id..end_user_id).find_each do |user| # rubocop: disable CodeReuse/ActiveRecord
......
...@@ -140,6 +140,7 @@ module Gitlab ...@@ -140,6 +140,7 @@ module Gitlab
def idempotent? def idempotent?
return false unless worker_klass return false unless worker_klass
return false unless worker_klass.respond_to?(:idempotent?) return false unless worker_klass.respond_to?(:idempotent?)
return false unless preserve_wal_location? || !worker_klass.utilizes_load_balancing_capabilities?
worker_klass.idempotent? worker_klass.idempotent?
end end
......
...@@ -472,6 +472,26 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gi ...@@ -472,6 +472,26 @@ RSpec.describe Gitlab::SidekiqMiddleware::DuplicateJobs::DuplicateJob, :clean_gi
expect(duplicate_job).to be_idempotent expect(duplicate_job).to be_idempotent
end end
end end
context 'when worker class is utilizing load balancing capabilities' do
before do
allow(AuthorizedProjectsWorker).to receive(:utilizes_load_balancing_capabilities?).and_return(true)
end
it 'returns true' do
expect(duplicate_job).to be_idempotent
end
context 'when preserve_latest_wal_locations_for_idempotent_jobs feature flag is disabled' do
before do
stub_feature_flags(preserve_latest_wal_locations_for_idempotent_jobs: false)
end
it 'returns false' do
expect(duplicate_job).not_to be_idempotent
end
end
end
end end
def existing_wal_location_key(idempotency_key, config_name) def existing_wal_location_key(idempotency_key, config_name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment