diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-12 11:58:06 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-12 15:54:05 +0200 |
commit | 0736397e0849333053390a24aa3938cda45707cf (patch) | |
tree | fdc3b2961be4f1b86694952153d49b2ad01db2df /app/services | |
parent | 97999fd4203846ad807de18eab5d7a2176344ce1 (diff) | |
download | gitlab-ce-0736397e0849333053390a24aa3938cda45707cf.tar.gz |
Reset project pushes_since_gc when we enqueue the git gc call
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/housekeeping_service.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/app/services/projects/housekeeping_service.rb b/app/services/projects/housekeeping_service.rb index c9ad710b7bf..29b3981f49f 100644 --- a/app/services/projects/housekeeping_service.rb +++ b/app/services/projects/housekeeping_service.rb @@ -22,11 +22,7 @@ module Projects def execute raise LeaseTaken unless try_obtain_lease - GitGarbageCollectWorker.perform_async(@project.id) - ensure - Gitlab::Metrics.measure(:reset_pushes_since_gc) do - update_pushes_since_gc(0) - end + execute_gitlab_shell_gc end def needed? @@ -34,19 +30,27 @@ module Projects end def increment! - Gitlab::Metrics.measure(:increment_pushes_since_gc) do - update_pushes_since_gc(@project.pushes_since_gc + 1) + if Gitlab::ExclusiveLease.new("project_housekeeping:increment!:#{@project.id}", timeout: 60).try_obtain + Gitlab::Metrics.measure(:increment_pushes_since_gc) do + update_pushes_since_gc(@project.pushes_since_gc + 1) + end 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) + def execute_gitlab_shell_gc + GitGarbageCollectWorker.perform_async(@project.id) + ensure + Gitlab::Metrics.measure(:reset_pushes_since_gc) do + update_pushes_since_gc(0) end end + def update_pushes_since_gc(new_value) + @project.update_column(:pushes_since_gc, new_value) + end + def try_obtain_lease Gitlab::Metrics.measure(:obtain_housekeeping_lease) do lease = ::Gitlab::ExclusiveLease.new("project_housekeeping:#{@project.id}", timeout: LEASE_TIMEOUT) |