debian-mirror-gitlab/lib/gitlab/database/async_indexes/index_creator.rb
2023-04-23 21:23:45 +05:30

35 lines
756 B
Ruby

# frozen_string_literal: true
module Gitlab
module Database
module AsyncIndexes
class IndexCreator < AsyncIndexes::IndexBase
STATEMENT_TIMEOUT = 20.hours
private
override :preconditions_met?
def preconditions_met?
!index_exists?
end
override :action_type
def action_type
'creation'
end
override :around_execution
def around_execution(&block)
set_statement_timeout(&block)
end
def set_statement_timeout
connection.execute("SET statement_timeout TO '%ds'" % STATEMENT_TIMEOUT)
yield
ensure
connection.execute('RESET statement_timeout')
end
end
end
end
end