summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2016-12-20 13:16:07 +0000
committerNick Thomas <nick@gitlab.com>2016-12-20 13:16:07 +0000
commit1139da2745eb28be17c8fd6aa0f5de113c0f06a9 (patch)
treecccbae8b3a7d46cc9d673b114cae143c8f70b5c5 /app/workers
parenta85220506eb3a7516008a1ffe67beff9550cdd1c (diff)
parentf73193c328b871a9a3af803012c10d9bc1bd0904 (diff)
downloadgitlab-ce-1139da2745eb28be17c8fd6aa0f5de113c0f06a9.tar.gz
Merge branch 'project-authorizations-diff' into 'master'
Smarter refreshing of authorized projects This MR reworks the way `User#refresh_authorized_projects`, resulting in a much more efficient process leading to fewer dead tuples. Related issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/25257 See merge request !7956
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/authorized_projects_worker.rb22
1 files changed, 1 insertions, 21 deletions
diff --git a/app/workers/authorized_projects_worker.rb b/app/workers/authorized_projects_worker.rb
index fccddb70d18..2badd0680fb 100644
--- a/app/workers/authorized_projects_worker.rb
+++ b/app/workers/authorized_projects_worker.rb
@@ -2,8 +2,6 @@ class AuthorizedProjectsWorker
include Sidekiq::Worker
include DedicatedSidekiqQueue
- LEASE_TIMEOUT = 1.minute.to_i
-
def self.bulk_perform_async(args_list)
Sidekiq::Client.push_bulk('class' => self, 'args' => args_list)
end
@@ -11,24 +9,6 @@ class AuthorizedProjectsWorker
def perform(user_id)
user = User.find_by(id: user_id)
- refresh(user) if user
- end
-
- def refresh(user)
- lease_key = "refresh_authorized_projects:#{user.id}"
- lease = Gitlab::ExclusiveLease.new(lease_key, timeout: LEASE_TIMEOUT)
-
- until uuid = lease.try_obtain
- # Keep trying until we obtain the lease. If we don't do so we may end up
- # not updating the list of authorized projects properly. To prevent
- # hammering Redis too much we'll wait for a bit between retries.
- sleep(1)
- end
-
- begin
- user.refresh_authorized_projects
- ensure
- Gitlab::ExclusiveLease.cancel(lease_key, uuid)
- end
+ user.refresh_authorized_projects if user
end
end