Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-28 16:14:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-28 16:14:44 +0300
commite7b5a68daecd0aff0cc66666cb38c7971027a05a (patch)
treeb153db785557cc807da5e623cb130a1ef384926e /lib
parentc8fb2e6a3942330079bde06d919cd33c6bc7600e (diff)
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'lib')
-rw-r--r--lib/backup/repository.rb42
-rw-r--r--lib/gitlab/config_checker/external_database_checker.rb55
-rw-r--r--lib/gitlab/database.rb30
3 files changed, 39 insertions, 88 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)
diff --git a/lib/gitlab/config_checker/external_database_checker.rb b/lib/gitlab/config_checker/external_database_checker.rb
index dfcdbdf39e0..606d45e0f0f 100644
--- a/lib/gitlab/config_checker/external_database_checker.rb
+++ b/lib/gitlab/config_checker/external_database_checker.rb
@@ -6,48 +6,21 @@ module Gitlab
extend self
def check
- notices = []
-
- unless Gitlab::Database.postgresql_minimum_supported_version?
- string_args = {
- pg_version_current: Gitlab::Database.version,
- pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
- pg_requirements_url_open: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">'.html_safe,
- pg_requirements_url_close: '</a>'.html_safe
+ return [] if Gitlab::Database.postgresql_minimum_supported_version?
+
+ [
+ {
+ type: 'warning',
+ message: _('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
+ '%{pg_version_minimum} is required for this version of GitLab. ' \
+ 'Please upgrade your environment to a supported PostgreSQL version, ' \
+ 'see %{pg_requirements_url} for details.') % {
+ pg_version_current: Gitlab::Database.version,
+ pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
+ pg_requirements_url: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">database requirements</a>'
+ }
}
-
- notices <<
- {
- type: 'warning',
- message: html_escape(_('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
- '%{pg_version_minimum} is required for this version of GitLab. ' \
- 'Please upgrade your environment to a supported PostgreSQL version, ' \
- 'see %{pg_requirements_url_open}database requirements%{pg_requirements_url_close} for details.')) % string_args
- }
- end
-
- if Gitlab::Database.postgresql_upcoming_deprecation? && Gitlab::Database.within_deprecation_notice_window?
- upcoming_deprecation = Gitlab::Database::UPCOMING_POSTGRES_VERSION_DETAILS
-
- string_args = {
- pg_version_upcoming: upcoming_deprecation[:pg_version_minimum],
- gl_version_upcoming: upcoming_deprecation[:gl_version],
- gl_version_upcoming_date: upcoming_deprecation[:gl_version_date],
- pg_version_upcoming_url_open: "<a href=\"#{upcoming_deprecation[:url]}\">".html_safe,
- pg_version_upcoming_url_close: '</a>'.html_safe
- }
-
- notices <<
- {
- type: 'warning',
- message: html_escape(_('Note that PostgreSQL %{pg_version_upcoming} will become the minimum required ' \
- 'version in GitLab %{gl_version_upcoming} (%{gl_version_upcoming_date}). Please ' \
- 'consider upgrading your environment to a supported PostgreSQL version soon, ' \
- 'see %{pg_version_upcoming_url_open}the related epic%{pg_version_upcoming_url_close} for details.')) % string_args
- }
- end
-
- notices
+ ]
end
end
end
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index e7df9fd27f0..990c940d200 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -6,20 +6,6 @@ module Gitlab
# https://docs.gitlab.com/ee/install/requirements.html#postgresql-requirements
MINIMUM_POSTGRES_VERSION = 11
- # Upcoming PostgreSQL version requirements
- # Allows a soft warning about an upcoming minimum version requirement
- # so administrators can prepare to upgrade
- UPCOMING_POSTGRES_VERSION_DETAILS = {
- gl_version: '13.6.0',
- gl_version_date: 'November 22, 2020',
- pg_version_minimum: 12,
- url: 'https://gitlab.com/groups/gitlab-org/-/epics/2374'
- }.freeze
-
- # Specifies the maximum number of days in advance to display a notice
- # regarding an upcoming PostgreSQL version deprecation.
- DEPRECATION_WINDOW_DAYS = 90
-
# https://www.postgresql.org/docs/9.2/static/datatype-numeric.html
MAX_INT_VALUE = 2147483647
MIN_INT_VALUE = -2147483648
@@ -114,22 +100,6 @@ module Gitlab
version.to_f >= MINIMUM_POSTGRES_VERSION
end
- def self.postgresql_upcoming_deprecation?
- version.to_f < UPCOMING_POSTGRES_VERSION_DETAILS[:pg_version_minimum]
- end
-
- def self.days_until_deprecation
- (
- Date.parse(UPCOMING_POSTGRES_VERSION_DETAILS[:gl_version_date]) -
- Date.today
- ).to_i
- end
- private_class_method :days_until_deprecation
-
- def self.within_deprecation_notice_window?
- days_until_deprecation <= DEPRECATION_WINDOW_DAYS
- end
-
def self.check_postgres_version_and_print_warning
return if Gitlab::Database.postgresql_minimum_supported_version?
return if Gitlab::Runtime.rails_runner?