diff options
author | Stan Hu <stanhu@gmail.com> | 2018-03-03 22:18:32 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-03-03 22:21:50 -0800 |
commit | 885998c220d76cf373669666dab5a2bb8dfbe023 (patch) | |
tree | 55da69c294c6de53ea6ceab97c10d3ec4a4e73c8 | |
parent | 8a0052c037f025b64159ca8cfe0d3451261c1edb (diff) | |
download | gitlab-ce-885998c220d76cf373669666dab5a2bb8dfbe023.tar.gz |
Release libgit2 cache and open file descriptors after `git gc` runsh-cleanup-after-git-gc
Relates to #21879
-rw-r--r-- | app/workers/git_garbage_collect_worker.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/sh-cleanup-after-git-gc.yml | 5 | ||||
-rw-r--r-- | spec/workers/git_garbage_collect_worker_spec.rb | 6 |
3 files changed, 15 insertions, 0 deletions
diff --git a/app/workers/git_garbage_collect_worker.rb b/app/workers/git_garbage_collect_worker.rb index 7ba224d74c8..55fb817ca6e 100644 --- a/app/workers/git_garbage_collect_worker.rb +++ b/app/workers/git_garbage_collect_worker.rb @@ -44,6 +44,10 @@ class GitGarbageCollectWorker # Refresh the branch cache in case garbage collection caused a ref lookup to fail flush_ref_caches(project) if task == :gc + + # In case pack files are deleted, release libgit2 cache and open file + # descriptors ASAP instead of waiting for Ruby garbage collection + project.cleanup ensure cancel_lease(lease_key, lease_uuid) if lease_key.present? && lease_uuid.present? end diff --git a/changelogs/unreleased/sh-cleanup-after-git-gc.yml b/changelogs/unreleased/sh-cleanup-after-git-gc.yml new file mode 100644 index 00000000000..4b652f4d6ce --- /dev/null +++ b/changelogs/unreleased/sh-cleanup-after-git-gc.yml @@ -0,0 +1,5 @@ +--- +title: Release libgit2 cache and open file descriptors after `git gc` run +merge_request: +author: +type: fixed diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb index 47297de738b..74539a7e493 100644 --- a/spec/workers/git_garbage_collect_worker_spec.rb +++ b/spec/workers/git_garbage_collect_worker_spec.rb @@ -195,6 +195,12 @@ describe GitGarbageCollectWorker do expect(File.exist?(bitmap_path(after_packs.first))).to eq(bitmaps_enabled) end + + it 'cleans up repository after finishing' do + expect_any_instance_of(Project).to receive(:cleanup).and_call_original + + subject.perform(project.id, 'gc', lease_key, lease_uuid) + end end context 'with bitmaps enabled' do |