diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-05-03 00:41:05 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-05-03 00:41:05 +0300 |
commit | d25239ee0b56a1f7c00d805949d0d0009037ee54 (patch) | |
tree | 1fd3e06bfed0744e4b33f211821abf221763f516 /app/workers | |
parent | 8163e233252f4335d8b2ccb11ced51a77944ee4d (diff) |
Use git_garbage_collect_worker to run pack_refs
PackRefs is not an expensive gitaly call - we want to
call it more often (than as part of full `gc`) because
it helps to keep number of refs files small - too many
refs file may be a problem for deployments with
slow storage.
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/git_garbage_collect_worker.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/workers/git_garbage_collect_worker.rb b/app/workers/git_garbage_collect_worker.rb index b33e9b1f718..d4a6f53dae5 100644 --- a/app/workers/git_garbage_collect_worker.rb +++ b/app/workers/git_garbage_collect_worker.rb @@ -29,7 +29,7 @@ class GitGarbageCollectWorker # Refresh the branch cache in case garbage collection caused a ref lookup to fail flush_ref_caches(project) if task == :gc - project.repository.expire_statistics_caches + project.repository.expire_statistics_caches if task != :pack_refs # In case pack files are deleted, release libgit2 cache and open file # descriptors ASAP instead of waiting for Ruby garbage collection @@ -58,7 +58,12 @@ class GitGarbageCollectWorker ## `repository` has to be a Gitlab::Git::Repository def gitaly_call(task, repository) - client = Gitlab::GitalyClient::RepositoryService.new(repository) + client = if task == :pack_refs + Gitlab::GitalyClient::RefService.new(repository) + else + Gitlab::GitalyClient::RepositoryService.new(repository) + end + case task when :gc client.garbage_collect(bitmaps_enabled?) @@ -66,6 +71,8 @@ class GitGarbageCollectWorker client.repack_full(bitmaps_enabled?) when :incremental_repack client.repack_incremental + when :pack_refs + client.pack_refs end rescue GRPC::NotFound => e Gitlab::GitLogger.error("#{__method__} failed:\nRepository not found") |