diff options
author | Stan Hu <stanhu@gmail.com> | 2019-03-31 16:38:23 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-04-01 19:33:16 +0300 |
commit | d4c6a3af78c0ef8257c453980832c4d419aabb51 (patch) | |
tree | 0bb125fa5169fd1fb75b7b3a6f757b8ad1ab77be /app | |
parent | 8813447c6fd6a9c843433cc7dfda6a95fc4c2b58 (diff) |
Force a full GC after importing a project
During a project import, it's possible that new branches are created by
the importer to handle pull requests that have been created from forked
projects, which would increment the `pushes_since_gc` value via
`HousekeepingService.increment!` before a full garbage collection gets
to run. This causes HousekeepingService to skip the full `git gc` and
move to the incremental repack mode. To ensure that a garbage collection
is run to pack refs and objects, explicitly execute the task.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59477
Diffstat (limited to 'app')
-rw-r--r-- | app/services/projects/after_import_service.rb | 2 | ||||
-rw-r--r-- | app/services/projects/housekeeping_service.rb | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/app/services/projects/after_import_service.rb b/app/services/projects/after_import_service.rb index bbdde4408d2..afb9048e87b 100644 --- a/app/services/projects/after_import_service.rb +++ b/app/services/projects/after_import_service.rb @@ -9,7 +9,7 @@ module Projects end def execute - Projects::HousekeepingService.new(@project).execute do + Projects::HousekeepingService.new(@project, :gc).execute do repository.delete_all_refs_except(RESERVED_REF_PREFIXES) end rescue Projects::HousekeepingService::LeaseTaken => e diff --git a/app/services/projects/housekeeping_service.rb b/app/services/projects/housekeeping_service.rb index 2f6dc4207dd..10bd5363b51 100644 --- a/app/services/projects/housekeeping_service.rb +++ b/app/services/projects/housekeeping_service.rb @@ -18,8 +18,9 @@ module Projects end end - def initialize(project) + def initialize(project, task = nil) @project = project + @task = task end def execute @@ -69,6 +70,8 @@ module Projects end def task + return @task if @task + if pushes_since_gc % gc_period == 0 :gc elsif pushes_since_gc % full_repack_period == 0 |