diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-01 18:10:20 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-01 18:10:20 +0000 |
commit | 0b4bb101eaea8ec7c26b5d4bccc3a5a565c721d4 (patch) | |
tree | caa37c67e707c54227e679832fc7cba2583a3363 /lib | |
parent | 2d9c043ab8b576ed254a900cc57ce0bd763dfdcf (diff) | |
download | gitlab-ce-0b4bb101eaea8ec7c26b5d4bccc3a5a565c721d4.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/api_guard.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/application_rate_limiter.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/database/postgres_index.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/database/reindexing.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/database/reindexing/concurrent_reindex.rb | 1 | ||||
-rw-r--r-- | lib/tasks/gitlab/db.rake | 2 |
6 files changed, 18 insertions, 4 deletions
diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb index 46b69214877..bf5044b4832 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -54,8 +54,10 @@ module API user = find_user_from_sources return unless user - # Sessions are enforced to be unavailable for API calls, so ignore them for admin mode - Gitlab::Auth::CurrentUserMode.bypass_session!(user.id) if Feature.enabled?(:user_mode_in_session) + if user.is_a?(User) && Feature.enabled?(:user_mode_in_session) + # Sessions are enforced to be unavailable for API calls, so ignore them for admin mode + Gitlab::Auth::CurrentUserMode.bypass_session!(user.id) + end unless api_access_allowed?(user) forbidden!(api_access_denied_message(user)) diff --git a/lib/gitlab/application_rate_limiter.rb b/lib/gitlab/application_rate_limiter.rb index 4eeec534fc0..6173918b453 100644 --- a/lib/gitlab/application_rate_limiter.rb +++ b/lib/gitlab/application_rate_limiter.rb @@ -31,7 +31,9 @@ module Gitlab group_export: { threshold: -> { application_settings.group_export_limit }, interval: 1.minute }, group_download_export: { threshold: -> { application_settings.group_download_export_limit }, interval: 1.minute }, group_import: { threshold: -> { application_settings.group_import_limit }, interval: 1.minute }, - group_testing_hook: { threshold: 5, interval: 1.minute } + group_testing_hook: { threshold: 5, interval: 1.minute }, + profile_add_new_email: { threshold: 5, interval: 1.minute }, + profile_resend_email_confirmation: { threshold: 5, interval: 1.minute } }.freeze end diff --git a/lib/gitlab/database/postgres_index.rb b/lib/gitlab/database/postgres_index.rb index 94b05d0b602..2a9f23f0098 100644 --- a/lib/gitlab/database/postgres_index.rb +++ b/lib/gitlab/database/postgres_index.rb @@ -21,6 +21,8 @@ module Gitlab limit(how_many).order(Arel.sql('RANDOM()')) end + scope :not_match, ->(regex) { where("name !~ ?", regex)} + def to_s name end diff --git a/lib/gitlab/database/reindexing.rb b/lib/gitlab/database/reindexing.rb index f93f2bab022..baffe28d9ed 100644 --- a/lib/gitlab/database/reindexing.rb +++ b/lib/gitlab/database/reindexing.rb @@ -10,6 +10,13 @@ module Gitlab end end end + + def self.candidate_indexes + Gitlab::Database::PostgresIndex + .regular + .not_match("^#{ConcurrentReindex::TEMPORARY_INDEX_PREFIX}") + .not_match("^#{ConcurrentReindex::REPLACED_INDEX_PREFIX}") + end end end end diff --git a/lib/gitlab/database/reindexing/concurrent_reindex.rb b/lib/gitlab/database/reindexing/concurrent_reindex.rb index b0d2be36d28..89fab4a183c 100644 --- a/lib/gitlab/database/reindexing/concurrent_reindex.rb +++ b/lib/gitlab/database/reindexing/concurrent_reindex.rb @@ -24,6 +24,7 @@ module Gitlab raise ReindexError, 'UNIQUE indexes are currently not supported' if index.unique? raise ReindexError, 'partitioned indexes are currently not supported' if index.partitioned? raise ReindexError, 'indexes serving an exclusion constraint are currently not supported' if index.exclusion? + raise ReindexError, 'index is a left-over temporary index from a previous reindexing run' if index.name.start_with?(TEMPORARY_INDEX_PREFIX, REPLACED_INDEX_PREFIX) logger.info "Starting reindex of #{index}" diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index edd031804a7..f54f65f4f48 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -177,7 +177,7 @@ namespace :gitlab do indexes = if args[:index_name] Gitlab::Database::PostgresIndex.by_identifier(args[:index_name]) else - Gitlab::Database::PostgresIndex.regular.random_few(2) + Gitlab::Database::Reindexing.candidate_indexes.random_few(2) end Gitlab::Database::Reindexing.perform(indexes) |