2021-01-03 14:25:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Database
|
|
|
|
module Reindexing
|
2021-02-22 17:27:13 +05:30
|
|
|
# Number of indexes to reindex per invocation
|
|
|
|
DEFAULT_INDEXES_PER_INVOCATION = 2
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
SUPPORTED_TYPES = %w(btree gist).freeze
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
# candidate_indexes: Array of Gitlab::Database::PostgresIndex
|
|
|
|
def self.perform(candidate_indexes, how_many: DEFAULT_INDEXES_PER_INVOCATION)
|
2021-03-08 18:12:59 +05:30
|
|
|
IndexSelection.new(candidate_indexes).take(how_many).each do |index|
|
|
|
|
Coordinator.new(index).perform
|
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def self.candidate_indexes
|
|
|
|
Gitlab::Database::PostgresIndex
|
2021-09-30 23:02:18 +05:30
|
|
|
.not_match("#{ReindexConcurrently::TEMPORARY_INDEX_PATTERN}$")
|
|
|
|
.reindexing_support
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|