diff options
author | Robert Speicher <robert@gitlab.com> | 2016-09-13 23:35:42 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-09-13 23:35:42 +0000 |
commit | 4f6ad25b0d306c7f84ce4ec795ecd3ca9280fef3 (patch) | |
tree | 86d58a883e82e58c5d9da8d7a27d3890e412ba93 /app/models | |
parent | 746bf485bc1ef7a7e46eda80ff6b450a14e5bf1d (diff) | |
parent | 4e87c02313241b1e0d36560a11014cb4b7992403 (diff) | |
download | gitlab-ce-4f6ad25b0d306c7f84ce4ec795ecd3ca9280fef3.tar.gz |
Merge branch 'pushes-since-gc-redis' into 'master'
19600-artifacts-show-up-in-interface-as-expired-immediately-although-configured-as-1-month-or-4-weeks
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/models')
-rw-r--r-- | app/models/project.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 4017cabe9f0..f3f3ffbbd28 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1288,8 +1288,24 @@ class Project < ActiveRecord::Base end end + def pushes_since_gc + Gitlab::Redis.with { |redis| redis.get(pushes_since_gc_redis_key).to_i } + end + + def increment_pushes_since_gc + Gitlab::Redis.with { |redis| redis.incr(pushes_since_gc_redis_key) } + end + + def reset_pushes_since_gc + Gitlab::Redis.with { |redis| redis.del(pushes_since_gc_redis_key) } + end + private + def pushes_since_gc_redis_key + "projects/#{id}/pushes_since_gc" + end + # Prevents the creation of project_feature record for every project def setup_project_feature build_project_feature unless project_feature |