diff options
Diffstat (limited to 'lib/tasks/gitlab')
-rw-r--r-- | lib/tasks/gitlab/db.rake | 45 | ||||
-rw-r--r-- | lib/tasks/gitlab/docs/compile_deprecations.rake | 2 | ||||
-rw-r--r-- | lib/tasks/gitlab/gitaly.rake | 3 | ||||
-rw-r--r-- | lib/tasks/gitlab/info.rake | 4 | ||||
-rw-r--r-- | lib/tasks/gitlab/sidekiq.rake | 7 | ||||
-rw-r--r-- | lib/tasks/gitlab/storage.rake | 2 |
6 files changed, 39 insertions, 24 deletions
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index e2647021914..e83c4cbdb39 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -160,35 +160,44 @@ namespace :gitlab do Rake::Task['gitlab:db:create_dynamic_partitions'].invoke end - desc 'reindex a regular index without downtime to eliminate bloat' - task :reindex, [:index_name] => :environment do |_, args| - unless Feature.enabled?(:database_reindexing, type: :ops) + desc 'execute reindexing without downtime to eliminate bloat' + task reindex: :environment do + unless Feature.enabled?(:database_reindexing, type: :ops, default_enabled: :yaml) puts "This feature (database_reindexing) is currently disabled.".color(:yellow) exit end - indexes = Gitlab::Database::PostgresIndex.reindexing_support + Gitlab::Database::EachDatabase.each_database_connection do |connection, connection_name| + Gitlab::Database::SharedModel.logger = Logger.new($stdout) if Gitlab::Utils.to_boolean(ENV['LOG_QUERIES_TO_CONSOLE'], default: false) - if identifier = args[:index_name] - raise ArgumentError, "Index name is not fully qualified with a schema: #{identifier}" unless identifier =~ /^\w+\.\w+$/ + # Hack: Before we do actual reindexing work, create async indexes + Gitlab::Database::AsyncIndexes.create_pending_indexes! if Feature.enabled?(:database_async_index_creation, type: :ops) - indexes = indexes.where(identifier: identifier) - - raise "Index not found or not supported: #{args[:index_name]}" if indexes.empty? + Gitlab::Database::Reindexing.automatic_reindexing end + rescue StandardError => e + Gitlab::AppLogger.error(e) + raise + end - ActiveRecord::Base.logger = Logger.new($stdout) if Gitlab::Utils.to_boolean(ENV['LOG_QUERIES_TO_CONSOLE'], default: false) + desc 'Enqueue an index for reindexing' + task :enqueue_reindexing_action, [:index_name, :database] => :environment do |_, args| + model = Gitlab::Database.database_base_models[args.fetch(:database, Gitlab::Database::PRIMARY_DATABASE_NAME)] - # Cleanup leftover temporary indexes from previous, possibly aborted runs (if any) - Gitlab::Database::Reindexing.cleanup_leftovers! + Gitlab::Database::SharedModel.using_connection(model.connection) do + queued_action = Gitlab::Database::PostgresIndex.find(args[:index_name]).queued_reindexing_actions.create! - # Hack: Before we do actual reindexing work, create async indexes - Gitlab::Database::AsyncIndexes.create_pending_indexes! if Feature.enabled?(:database_async_index_creation, type: :ops) + puts "Queued reindexing action: #{queued_action}" + puts "There are #{Gitlab::Database::Reindexing::QueuedAction.queued.size} queued actions in total." + end - Gitlab::Database::Reindexing.perform(indexes) - rescue StandardError => e - Gitlab::AppLogger.error(e) - raise + unless Feature.enabled?(:database_reindexing, type: :ops, default_enabled: :yaml) + puts <<~NOTE.color(:yellow) + Note: database_reindexing feature is currently disabled. + + Enable with: Feature.enable(:database_reindexing) + NOTE + end end desc 'Check if there have been user additions to the database' diff --git a/lib/tasks/gitlab/docs/compile_deprecations.rake b/lib/tasks/gitlab/docs/compile_deprecations.rake index 0fd43775015..dc9788cb0b2 100644 --- a/lib/tasks/gitlab/docs/compile_deprecations.rake +++ b/lib/tasks/gitlab/docs/compile_deprecations.rake @@ -21,7 +21,7 @@ namespace :gitlab do if doc == contents puts "Deprecations doc is up to date." else - format_output('Deprecations doc is outdated! Please update it by running `bundle exec rake gitlab:docs:compile_deprecations`.') + format_output('Deprecations doc is outdated! You (or your technical writer) can update it by running `bin/rake gitlab:docs:compile_deprecations`.') abort end end diff --git a/lib/tasks/gitlab/gitaly.rake b/lib/tasks/gitlab/gitaly.rake index ef58c9339f1..eabbb8652f1 100644 --- a/lib/tasks/gitlab/gitaly.rake +++ b/lib/tasks/gitlab/gitaly.rake @@ -67,7 +67,8 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]") env["BUNDLE_DEPLOYMENT"] = 'false' end - Gitlab::Popen.popen([make_cmd], nil, env) + output, status = Gitlab::Popen.popen([make_cmd, 'all', 'git'], nil, env) + raise "Gitaly failed to compile: #{output}" unless status&.zero? end end end diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake index 68395d10d24..02764b5d46f 100644 --- a/lib/tasks/gitlab/info.rake +++ b/lib/tasks/gitlab/info.rake @@ -68,8 +68,8 @@ namespace :gitlab do puts "Version:\t#{Gitlab::VERSION}" puts "Revision:\t#{Gitlab.revision}" puts "Directory:\t#{Rails.root}" - puts "DB Adapter:\t#{Gitlab::Database.main.human_adapter_name}" - puts "DB Version:\t#{Gitlab::Database.main.version}" + puts "DB Adapter:\t#{ApplicationRecord.database.human_adapter_name}" + puts "DB Version:\t#{ApplicationRecord.database.version}" puts "URL:\t\t#{Gitlab.config.gitlab.url}" puts "HTTP Clone URL:\t#{http_clone_url}" puts "SSH Clone URL:\t#{ssh_clone_url}" diff --git a/lib/tasks/gitlab/sidekiq.rake b/lib/tasks/gitlab/sidekiq.rake index 90ed91221ae..2e383065b64 100644 --- a/lib/tasks/gitlab/sidekiq.rake +++ b/lib/tasks/gitlab/sidekiq.rake @@ -36,13 +36,17 @@ namespace :gitlab do # Do not edit it manually! BANNER - foss_workers, ee_workers = Gitlab::SidekiqConfig.workers_for_all_queues_yml + foss_workers, ee_workers, jh_workers = Gitlab::SidekiqConfig.workers_for_all_queues_yml write_yaml(Gitlab::SidekiqConfig::FOSS_QUEUE_CONFIG_PATH, banner, foss_workers) if Gitlab.ee? write_yaml(Gitlab::SidekiqConfig::EE_QUEUE_CONFIG_PATH, banner, ee_workers) end + + if Gitlab.jh? + write_yaml(Gitlab::SidekiqConfig::JH_QUEUE_CONFIG_PATH, banner, jh_workers) + end end desc 'GitLab | Sidekiq | Validate that all_queues.yml matches worker definitions' @@ -57,6 +61,7 @@ namespace :gitlab do - #{Gitlab::SidekiqConfig::FOSS_QUEUE_CONFIG_PATH} - #{Gitlab::SidekiqConfig::EE_QUEUE_CONFIG_PATH} + #{"- " + Gitlab::SidekiqConfig::JH_QUEUE_CONFIG_PATH if Gitlab.jh?} MSG end diff --git a/lib/tasks/gitlab/storage.rake b/lib/tasks/gitlab/storage.rake index fb9f9b9fe67..eb5eeed531f 100644 --- a/lib/tasks/gitlab/storage.rake +++ b/lib/tasks/gitlab/storage.rake @@ -170,7 +170,7 @@ namespace :gitlab do inverval = (ENV['MAX_DATABASE_CONNECTION_CHECK_INTERVAL'] || 10).to_f attempts.to_i.times do - unless Gitlab::Database.main.exists? + unless ApplicationRecord.database.exists? puts "Waiting until database is ready before continuing...".color(:yellow) sleep inverval end |