diff options
Diffstat (limited to 'lib/gitlab/database/async_indexes.rb')
-rw-r--r-- | lib/gitlab/database/async_indexes.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/gitlab/database/async_indexes.rb b/lib/gitlab/database/async_indexes.rb index 6f301a66803..581c7e7ff94 100644 --- a/lib/gitlab/database/async_indexes.rb +++ b/lib/gitlab/database/async_indexes.rb @@ -16,6 +16,15 @@ module Gitlab IndexDestructor.new(async_index).perform end end + + def self.execute_pending_actions!(how_many: DEFAULT_INDEXES_PER_INVOCATION) + queue_ids = PostgresAsyncIndex.ordered.limit(how_many).pluck(:id) + removal_actions = PostgresAsyncIndex.where(id: queue_ids).to_drop.ordered + creation_actions = PostgresAsyncIndex.where(id: queue_ids).to_create.ordered + + removal_actions.each { |async_index| IndexDestructor.new(async_index).perform } + creation_actions.each { |async_index| IndexCreator.new(async_index).perform } + end end end end |