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

Run UserRefreshFromReplicaWorker jobs on the replica db by default

This change runs `UserRefreshFromReplicaWorker`
jobs on the replica database by default (if available),
so that all data is read from the replica database
(and not the primary), there by reducing the
number of reads hitting the primary database.

Changelog: performance
parent 3cef7987
......@@ -14,19 +14,12 @@ module AuthorizedProjectUpdate
deduplicate :until_executing, including_scheduled: true
def perform(user_id)
if Feature.enabled?(:user_refresh_from_replica_worker_uses_replica_db)
use_replica_if_available do
user = User.find_by_id(user_id)
if user && project_authorizations_needs_refresh?(user)
enqueue_project_authorizations_refresh(user)
end
end
else
use_replica_if_available do
user = User.find_by_id(user_id)
return unless user
user.refresh_authorized_projects(source: self.class.name)
if user && project_authorizations_needs_refresh?(user)
enqueue_project_authorizations_refresh(user)
end
end
end
......
---
name: user_refresh_from_replica_worker_uses_replica_db
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64276
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/334766
milestone: '14.1'
type: development
group: group::access
default_enabled: false
......@@ -51,20 +51,5 @@ RSpec.describe AuthorizedProjectUpdate::UserRefreshFromReplicaWorker do
execute_worker
end
end
context 'when the feature flag `user_refresh_from_replica_worker_uses_replica_db` is disabled' do
before do
stub_feature_flags(user_refresh_from_replica_worker_uses_replica_db: false)
end
it 'calls Users::RefreshAuthorizedProjectsService' do
source = 'AuthorizedProjectUpdate::UserRefreshFromReplicaWorker'
expect_next_instance_of(Users::RefreshAuthorizedProjectsService, user, { source: source }) do |service|
expect(service).to receive(:execute)
end
execute_worker
end
end
end
end
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