summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-09-13 18:28:45 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2016-09-13 22:27:51 +0200
commit4e87c02313241b1e0d36560a11014cb4b7992403 (patch)
treea62fc802d87f503bc7b7b6dc5113d4dab1d3f241 /app/services
parenta0c46221626ae367c3da68e38a6d5dde7dda32db (diff)
downloadgitlab-ce-4e87c02313241b1e0d36560a11014cb4b7992403.tar.gz
Move pushes_since_gc to Redispushes-since-gc-redis
This moves tracking of the pushes since the last Git GC from PostgreSQL to Redis. This reduces the number of writes on the "projects" table. This in turn reduces the vacuuming overhead. The lease used for incrementing the counter has been removed. This lease was mostly put in place to prevent high database load but this isn't needed anymore due to the counter now being stored in Redis. Fixes gitlab-org/gitlab-ce#22125
Diffstat (limited to 'app/services')
-rw-r--r--app/services/projects/housekeeping_service.rb12
1 files changed, 3 insertions, 9 deletions
diff --git a/app/services/projects/housekeeping_service.rb b/app/services/projects/housekeeping_service.rb
index 29b3981f49f..c3dfc8cfbe8 100644
--- a/app/services/projects/housekeeping_service.rb
+++ b/app/services/projects/housekeeping_service.rb
@@ -30,10 +30,8 @@ module Projects
end
def increment!
- 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
+ Gitlab::Metrics.measure(:increment_pushes_since_gc) do
+ @project.increment_pushes_since_gc
end
end
@@ -43,14 +41,10 @@ module Projects
GitGarbageCollectWorker.perform_async(@project.id)
ensure
Gitlab::Metrics.measure(:reset_pushes_since_gc) do
- update_pushes_since_gc(0)
+ @project.reset_pushes_since_gc
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)