2022-08-27 11:52:29 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Database
|
|
|
|
module AsyncIndexes
|
2023-04-23 21:23:45 +05:30
|
|
|
class IndexDestructor < AsyncIndexes::IndexBase
|
2022-08-27 11:52:29 +05:30
|
|
|
private
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
override :preconditions_met?
|
|
|
|
def preconditions_met?
|
|
|
|
index_exists?
|
2022-08-27 11:52:29 +05:30
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
override :action_type
|
|
|
|
def action_type
|
|
|
|
'removal'
|
2022-08-27 11:52:29 +05:30
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
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
|
|
|
|
)
|
2022-08-27 11:52:29 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
retries.run(raise_on_exhaustion: false, &block)
|
2022-08-27 11:52:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|