Close low level rugged repository in project cache worker

Signed-off-by: Bastian Blank <waldi@debian.org>
This commit is contained in:
Bastian Blank 2018-02-05 17:36:51 +00:00
parent 1214d8de69
commit 285d5d526b
5 changed files with 19 additions and 1 deletions

View file

@ -511,10 +511,13 @@ class Project < ActiveRecord::Base
@repository ||= Repository.new(full_path, self, disk_path: disk_path)
end
def reload_repository!
def cleanup
@repository&.cleanup
@repository = nil
end
alias_method :reload_repository!, :cleanup
def container_registry_url
if Gitlab.config.registry.enabled
"#{Gitlab.config.registry.host_port}/#{full_path.downcase}"

View file

@ -93,6 +93,10 @@ class Repository
alias_method :raw, :raw_repository
def cleanup
@raw_repository&.cleanup
end
# Return absolute path to repository
def path_to_repo
@path_to_repo ||= File.expand_path(

View file

@ -18,6 +18,8 @@ class ProjectCacheWorker
update_statistics(project, statistics.map(&:to_sym))
project.repository.refresh_method_caches(files.map(&:to_sym))
project.cleanup
end
def update_statistics(project, statistics = [])

View file

@ -0,0 +1,5 @@
---
title: Close low level rugged repository in project cache worker
merge_request: 16930
author: Bastian Blank
type: fixed

View file

@ -128,6 +128,10 @@ module Gitlab
raise NoRepository.new('no repository for such path')
end
def cleanup
@rugged&.close
end
def circuit_breaker
@circuit_breaker ||= Gitlab::Git::Storage::CircuitBreaker.for_storage(storage)
end