debian-mirror-gitlab/lib/gitlab/database/async_indexes/index_creator.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
756 B
Ruby
Raw Normal View History

2021-10-27 15:23:28 +05:30
# frozen_string_literal: true
module Gitlab
module Database
module AsyncIndexes
2023-04-23 21:23:45 +05:30
class IndexCreator < AsyncIndexes::IndexBase
2023-03-17 16:20:25 +05:30
STATEMENT_TIMEOUT = 20.hours
2021-10-27 15:23:28 +05:30
private
2023-04-23 21:23:45 +05:30
override :preconditions_met?
def preconditions_met?
!index_exists?
2021-10-27 15:23:28 +05:30
end
2023-04-23 21:23:45 +05:30
override :action_type
def action_type
'creation'
2021-10-27 15:23:28 +05:30
end
2023-04-23 21:23:45 +05:30
override :around_execution
def around_execution(&block)
set_statement_timeout(&block)
2021-10-27 15:23:28 +05:30
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