Disable PostgreSQL statement timeout during migrations
Long-running migrations may take more than the timeout allowed by the database. Disable the session's statement timeout to ensure migrations don't get killed prematurely.
This commit is contained in:
parent
7968484dfa
commit
e5c7e11840
2 changed files with 9 additions and 0 deletions
|
@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
|
|||
|
||||
v 8.10.0 (unreleased)
|
||||
- Expose {should,force}_remove_source_branch (Ben Boeckel)
|
||||
- Disable PostgreSQL statement timeout during migrations
|
||||
- Fix projects dropdown loading performance with a simplified api cal. !5113 (tiagonbotelho)
|
||||
- Fix commit builds API, return all builds for all pipelines for given commit. !4849
|
||||
- Replace Haml with Hamlit to make view rendering faster. !3666
|
||||
|
|
|
@ -25,6 +25,13 @@ module Gitlab
|
|||
add_index(table_name, column_name, options)
|
||||
end
|
||||
|
||||
# Long-running migrations may take more than the timeout allowed by
|
||||
# the database. Disable the session's statement timeout to ensure
|
||||
# migrations don't get killed prematurely. (PostgreSQL only)
|
||||
def disable_statement_timeout
|
||||
ActiveRecord::Base.connection.execute('SET statement_timeout TO 0') if Database.postgresql?
|
||||
end
|
||||
|
||||
# Updates the value of a column in batches.
|
||||
#
|
||||
# This method updates the table in batches of 5% of the total row count.
|
||||
|
@ -134,6 +141,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
transaction do
|
||||
disable_statement_timeout
|
||||
add_column(table, column, type, default: nil)
|
||||
|
||||
# Changing the default before the update ensures any newly inserted
|
||||
|
|
Loading…
Reference in a new issue