diff options
author | Robert Speicher <robert@gitlab.com> | 2016-09-14 02:35:42 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-09-14 02:35:42 +0300 |
commit | 4f6ad25b0d306c7f84ce4ec795ecd3ca9280fef3 (patch) | |
tree | 86d58a883e82e58c5d9da8d7a27d3890e412ba93 /app/services | |
parent | 746bf485bc1ef7a7e46eda80ff6b450a14e5bf1d (diff) | |
parent | 4e87c02313241b1e0d36560a11014cb4b7992403 (diff) |
Merge branch 'pushes-since-gc-redis' into 'master'
Move pushes_since_gc to Redis
## What does this MR do?
This moves tracking of the pushes since the last Git GC to Redis to reduce DB load.
## Are there points in the code the reviewer needs to double check?
Styling mostly.
## Why was this MR needed?
Updating this column can lead to a lot of writes which in turn puts a lot of load on table vacuuming. For example, in the last hour alone we had 5067 UPDATEs for this column (per InfluxDB):
```
> select count(increment_pushes_since_gc_call_count) from sidekiq_transactions where time > now() - 1h;
name: sidekiq_transactions
--------------------------
time count
1473780996567714622 5067
```
## What are the relevant issue numbers?
https://gitlab.com/gitlab-org/gitlab-ce/issues/22125
See merge request !6326
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/housekeeping_service.rb | 12 |
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) |