Commit 22780c4a authored by Douwe Maan's avatar Douwe Maan

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]( entry added
- ~~[ ] [Documentation created/updated](
- ~~[ ] API support added~~
- Tests
  - ~~[ ] Added for this feature/bug~~
  - [x] All builds are passing
- [x] Conform by the [style guides](
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](

See merge request !5083
parents b5b17d00 d91c6c07
Pipeline #3657877 passed with stages
in 1112 minutes and 40 seconds
......@@ -26,6 +26,7 @@ v 8.10.0 (unreleased)
- Add "Enabled Git access protocols" to Application Settings
- Fix user creation with stronger minimum password requirements !4054 (nathan-pmt)
- PipelinesFinder uses git cache data
- Throttle the update of `project.pushes_since_gc` to 1 minute.
- Check for conflicts with existing Project's wiki path when creating a new project.
- Don't instantiate a git tree on Projects show default view
- Bump Rinku to 2.0.0
......@@ -27,7 +27,7 @@ module Projects
GitlabShellOneShotWorker.perform_async(:gc, @project.repository_storage_path, @project.path_with_namespace)
Gitlab::Metrics.measure(:reset_pushes_since_gc) do
@project.update_column(:pushes_since_gc, 0)
......@@ -37,12 +37,18 @@ module Projects
def increment!
Gitlab::Metrics.measure(:increment_pushes_since_gc) do
update_pushes_since_gc(@project.pushes_since_gc + 1)
def update_pushes_since_gc(new_value)
if"project_housekeeping:update_pushes_since_gc:#{}", timeout: 60).try_obtain
@project.update_column(:pushes_since_gc, new_value)
def try_obtain_lease
Gitlab::Metrics.measure(:obtain_housekeeping_lease) do
lease ="project_housekeeping:#{}", timeout: LEASE_TIMEOUT)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment