Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-07-06 18:53:04 +0300
committerDouwe Maan <douwe@gitlab.com>2016-07-06 18:53:04 +0300
commit22780c4ac32a29347317a979c4b8bdf2913d34f7 (patch)
treebdc81e27cef322475f2f272c6b9f855d01f0f4f5 /app/services/projects
parentb5b17d00eddef8011e3a71d5f4ad46c6d40cbf8a (diff)
parentd91c6c0738086f4ff8f99fabb78efd90bed990a0 (diff)
Merge branch '15094-throttling-pushes_since_gc' into 'master'
Throttle the update of `project.pushes_since_gc` to 1 minute ## What does this MR do? Throttle the update of `project.pushes_since_gc` to alleviate DB load ## What are the relevant issue numbers? Relates to #15094 ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - ~~[ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~ - ~~[ ] API support added~~ - Tests - ~~[ ] Added for this feature/bug~~ - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5083
Diffstat (limited to 'app/services/projects')
-rw-r--r--app/services/projects/housekeeping_service.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/services/projects/housekeeping_service.rb b/app/services/projects/housekeeping_service.rb
index a47df22f1ba..752c11d7ae6 100644
--- a/app/services/projects/housekeeping_service.rb
+++ b/app/services/projects/housekeeping_service.rb
@@ -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)