mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-09 04:36:11 +10:00
Throttle the update of project.pushes_since_gc to 1 minute
This commit is contained in:
@@ -23,6 +23,7 @@ v 8.10.0 (unreleased)
|
||||
- API: Todos !3188 (Robert Schilling)
|
||||
- Fix user creation with stronger minimum password requirements !4054 (nathan-pmt)
|
||||
- PipelinesFinder uses git cache data
|
||||
- Throttle the update of `project.pushes_since_gc` to 1 minute.
|
||||
- Check for conflicts with existing Project's wiki path when creating a new project.
|
||||
- Don't instantiate a git tree on Projects show default view
|
||||
- Remove unused front-end variable -> default_issues_tracker
|
||||
|
||||
@@ -27,7 +27,7 @@ module Projects
|
||||
GitlabShellOneShotWorker.perform_async(:gc, @project.repository_storage_path, @project.path_with_namespace)
|
||||
ensure
|
||||
Gitlab::Metrics.measure(:reset_pushes_since_gc) do
|
||||
@project.update_column(:pushes_since_gc, 0)
|
||||
update_pushes_since_gc(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,12 +37,18 @@ module Projects
|
||||
|
||||
def increment!
|
||||
Gitlab::Metrics.measure(:increment_pushes_since_gc) do
|
||||
@project.increment!(:pushes_since_gc)
|
||||
update_pushes_since_gc(@project.pushes_since_gc + 1)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_pushes_since_gc(new_value)
|
||||
if Gitlab::ExclusiveLease.new("project_housekeeping:update_pushes_since_gc:#{project.id}", timeout: 60).try_obtain
|
||||
@project.update_column(:pushes_since_gc, new_value)
|
||||
end
|
||||
end
|
||||
|
||||
def try_obtain_lease
|
||||
Gitlab::Metrics.measure(:obtain_housekeeping_lease) do
|
||||
lease = ::Gitlab::ExclusiveLease.new("project_housekeeping:#{@project.id}", timeout: LEASE_TIMEOUT)
|
||||
|
||||
Reference in New Issue
Block a user