Commit f444387b authored by Manoj M J's avatar Manoj M J

Use a new worker in lieu of UserRefreshWithLowUrgencyWorker as safeguard

Changelog: other
parent 50b9d851
...@@ -20,7 +20,7 @@ class UserProjectAccessChangedService ...@@ -20,7 +20,7 @@ class UserProjectAccessChangedService
if priority == HIGH_PRIORITY if priority == HIGH_PRIORITY
AuthorizedProjectsWorker.bulk_perform_async(bulk_args) # rubocop:disable Scalability/BulkPerformWithContext AuthorizedProjectsWorker.bulk_perform_async(bulk_args) # rubocop:disable Scalability/BulkPerformWithContext
else else
AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker.bulk_perform_in( # rubocop:disable Scalability/BulkPerformWithContext AuthorizedProjectUpdate::UserRefreshFromReplicaWorker.bulk_perform_in( # rubocop:disable Scalability/BulkPerformWithContext
DELAY, bulk_args, batch_size: 100, batch_delay: 30.seconds) DELAY, bulk_args, batch_size: 100, batch_delay: 30.seconds)
end end
end end
......
...@@ -30,6 +30,15 @@ ...@@ -30,6 +30,15 @@
:weight: 1 :weight: 1
:idempotent: true :idempotent: true
:tags: [] :tags: []
- :name: authorized_project_update:authorized_project_update_user_refresh_from_replica
:worker_name: AuthorizedProjectUpdate::UserRefreshFromReplicaWorker
:feature_category: :authentication_and_authorization
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent: true
:tags: []
- :name: authorized_project_update:authorized_project_update_user_refresh_over_user_range - :name: authorized_project_update:authorized_project_update_user_refresh_over_user_range
:worker_name: AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker :worker_name: AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker
:feature_category: :authentication_and_authorization :feature_category: :authentication_and_authorization
......
# frozen_string_literal: true
module AuthorizedProjectUpdate
class UserRefreshFromReplicaWorker < ::AuthorizedProjectsWorker
feature_category :authentication_and_authorization
urgency :low
queue_namespace :authorized_project_update
deduplicate :until_executing, including_scheduled: true
idempotent!
# This worker will start reading data from the replica database soon
# Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/333219
end
end
...@@ -837,7 +837,7 @@ RSpec.describe Projects::CreateService, '#execute' do ...@@ -837,7 +837,7 @@ RSpec.describe Projects::CreateService, '#execute' do
expect(AuthorizedProjectUpdate::ProjectCreateWorker).to( expect(AuthorizedProjectUpdate::ProjectCreateWorker).to(
receive(:perform_async).and_call_original receive(:perform_async).and_call_original
) )
expect(AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker).to( expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to(
receive(:bulk_perform_in) receive(:bulk_perform_in)
.with(1.hour, .with(1.hour,
array_including([user.id], [other_user.id]), array_including([user.id], [other_user.id]),
......
...@@ -54,7 +54,7 @@ RSpec.describe Projects::GroupLinks::CreateService, '#execute' do ...@@ -54,7 +54,7 @@ RSpec.describe Projects::GroupLinks::CreateService, '#execute' do
.with(project.id, group.id, group_access) .with(project.id, group.id, group_access)
.and_call_original .and_call_original
) )
expect(AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker).to( expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to(
receive(:bulk_perform_in) receive(:bulk_perform_in)
.with(1.hour, .with(1.hour,
array_including([user.id], [other_user.id]), array_including([user.id], [other_user.id]),
......
...@@ -31,8 +31,8 @@ RSpec.describe Projects::GroupLinks::DestroyService, '#execute' do ...@@ -31,8 +31,8 @@ RSpec.describe Projects::GroupLinks::DestroyService, '#execute' do
subject.execute(group_link) subject.execute(group_link)
end end
it 'calls AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker with a delay to update project authorizations' do it 'calls AuthorizedProjectUpdate::UserRefreshFromReplicaWorker with a delay to update project authorizations' do
expect(AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker).to( expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to(
receive(:bulk_perform_in) receive(:bulk_perform_in)
.with(1.hour, .with(1.hour,
[[user.id]], [[user.id]],
......
...@@ -19,7 +19,7 @@ RSpec.describe UserProjectAccessChangedService do ...@@ -19,7 +19,7 @@ RSpec.describe UserProjectAccessChangedService do
end end
it 'permits low-priority operation' do it 'permits low-priority operation' do
expect(AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker).to( expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to(
receive(:bulk_perform_in).with( receive(:bulk_perform_in).with(
described_class::DELAY, described_class::DELAY,
[[1], [2]], [[1], [2]],
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe AuthorizedProjectUpdate::UserRefreshFromReplicaWorker do
it 'is labeled as low urgency' do
expect(described_class.get_urgency).to eq(:low)
end
it_behaves_like "refreshes user's project authorizations"
end
...@@ -130,6 +130,7 @@ RSpec.describe 'Every Sidekiq worker' do ...@@ -130,6 +130,7 @@ RSpec.describe 'Every Sidekiq worker' do
'AuthorizedProjectUpdate::ProjectGroupLinkCreateWorker' => 3, 'AuthorizedProjectUpdate::ProjectGroupLinkCreateWorker' => 3,
'AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker' => 3, 'AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker' => 3,
'AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker' => 3, 'AuthorizedProjectUpdate::UserRefreshWithLowUrgencyWorker' => 3,
'AuthorizedProjectUpdate::UserRefreshFromReplicaWorker' => 3,
'AuthorizedProjectsWorker' => 3, 'AuthorizedProjectsWorker' => 3,
'AutoDevops::DisableWorker' => 3, 'AutoDevops::DisableWorker' => 3,
'AutoMergeProcessWorker' => 3, 'AutoMergeProcessWorker' => 3,
......
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