Free open file descriptors and libgit2 buffers in UpdatePagesService

In UpdatePagesService, we were seeing a large number of open pack files in
production. Calling Project#cleanup removes a reference to Rugged::Repository
and forces libgit2 to close file descriptors and free its internal memory
cache.

Relates to https://gitlab.com/gitlab-com/infrastructure/issues/3965#note_65837525
This commit is contained in:
Stan Hu 2018-03-30 01:20:32 -07:00
parent 9b76d8512a
commit cc82abbde0
2 changed files with 8 additions and 0 deletions

View file

@ -178,6 +178,9 @@ module Projects
def latest_sha
project.commit(build.ref).try(:sha).to_s
ensure
# Close any file descriptors that were opened and free libgit2 buffers
project.cleanup
end
def sha

View file

@ -0,0 +1,5 @@
---
title: Free open file descriptors and libgit2 buffers in UpdatePagesService
merge_request:
author:
type: performance