BigW Consortium Gitlab

Commit 7095c2bf by Douwe Maan

Merge branch '42730-close-rugged-repository' into 'master'

Resolve "ProjectCacheWorker leaks file descriptors" Closes #42730 See merge request gitlab-org/gitlab-ce!16930
parents a480ee18 285d5d52
...@@ -511,10 +511,13 @@ class Project < ActiveRecord::Base ...@@ -511,10 +511,13 @@ class Project < ActiveRecord::Base
@repository ||= Repository.new(full_path, self, disk_path: disk_path) @repository ||= Repository.new(full_path, self, disk_path: disk_path)
end end
def reload_repository! def cleanup
@repository&.cleanup
@repository = nil @repository = nil
end end
alias_method :reload_repository!, :cleanup
def container_registry_url def container_registry_url
if Gitlab.config.registry.enabled if Gitlab.config.registry.enabled
"#{Gitlab.config.registry.host_port}/#{full_path.downcase}" "#{Gitlab.config.registry.host_port}/#{full_path.downcase}"
......
...@@ -93,6 +93,10 @@ class Repository ...@@ -93,6 +93,10 @@ class Repository
alias_method :raw, :raw_repository alias_method :raw, :raw_repository
def cleanup
@raw_repository&.cleanup
end
# Return absolute path to repository # Return absolute path to repository
def path_to_repo def path_to_repo
@path_to_repo ||= File.expand_path( @path_to_repo ||= File.expand_path(
......
...@@ -18,6 +18,8 @@ class ProjectCacheWorker ...@@ -18,6 +18,8 @@ class ProjectCacheWorker
update_statistics(project, statistics.map(&:to_sym)) update_statistics(project, statistics.map(&:to_sym))
project.repository.refresh_method_caches(files.map(&:to_sym)) project.repository.refresh_method_caches(files.map(&:to_sym))
project.cleanup
end end
def update_statistics(project, statistics = []) def update_statistics(project, statistics = [])
......
---
title: Close low level rugged repository in project cache worker
merge_request: 16930
author: Bastian Blank
type: fixed
...@@ -128,6 +128,10 @@ module Gitlab ...@@ -128,6 +128,10 @@ module Gitlab
raise NoRepository.new('no repository for such path') raise NoRepository.new('no repository for such path')
end end
def cleanup
@rugged&.close
end
def circuit_breaker def circuit_breaker
@circuit_breaker ||= Gitlab::Git::Storage::CircuitBreaker.for_storage(storage) @circuit_breaker ||= Gitlab::Git::Storage::CircuitBreaker.for_storage(storage)
end end
......
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