diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-28 16:14:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-28 16:14:44 +0300 |
commit | e7b5a68daecd0aff0cc66666cb38c7971027a05a (patch) | |
tree | b153db785557cc807da5e623cb130a1ef384926e /lib/backup | |
parent | c8fb2e6a3942330079bde06d919cd33c6bc7600e (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'lib/backup')
-rw-r--r-- | lib/backup/repository.rb | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 1daa29f00ef..51fac9e8706 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -26,13 +26,17 @@ module Backup threads = Gitlab.config.repositories.storages.keys.map do |storage| Thread.new do - dump_storage(storage, semaphore, max_storage_concurrency: max_storage_concurrency) - rescue => e - errors << e + Rails.application.executor.wrap do + dump_storage(storage, semaphore, max_storage_concurrency: max_storage_concurrency) + rescue => e + errors << e + end end end - threads.each(&:join) + ActiveSupport::Dependencies.interlock.permit_concurrent_loads do + threads.each(&:join) + end raise errors.pop unless errors.empty? end @@ -155,16 +159,18 @@ module Backup threads = Array.new(max_storage_concurrency) do Thread.new do - while project = queue.pop - semaphore.acquire - - begin - dump_project(project) - rescue => e - errors << e - break - ensure - semaphore.release + Rails.application.executor.wrap do + while project = queue.pop + semaphore.acquire + + begin + dump_project(project) + rescue => e + errors << e + break + ensure + semaphore.release + end end end end @@ -176,10 +182,12 @@ module Backup queue.push(project) end - queue.close - threads.each(&:join) - raise errors.pop unless errors.empty? + ensure + queue.close + ActiveSupport::Dependencies.interlock.permit_concurrent_loads do + threads.each(&:join) + end end def dump_project(project) |