summaryrefslogtreecommitdiff
path: root/lib/gitlab/database/async_indexes/index_destructor.rb
blob: 5596e099cb6622d892b4cf7080b5752e9008f259 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Gitlab
  module Database
    module AsyncIndexes
      class IndexDestructor < AsyncIndexes::IndexBase
        private

        override :preconditions_met?
        def preconditions_met?
          index_exists?
        end

        override :action_type
        def action_type
          'removal'
        end

        override :around_execution
        def around_execution(&block)
          retries = Gitlab::Database::WithLockRetriesOutsideTransaction.new(
            connection: connection,
            timing_configuration: Gitlab::Database::Reindexing::REMOVE_INDEX_RETRY_CONFIG,
            klass: self.class,
            logger: Gitlab::AppLogger
          )

          retries.run(raise_on_exhaustion: false, &block)
        end
      end
    end
  end
end