diff options
author | Stan Hu <stanhu@gmail.com> | 2016-07-14 18:39:08 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-07-14 18:40:54 -0700 |
commit | e5c7e11840871e3138ad32693d86de8d7cd7c670 (patch) | |
tree | 6c3a84175ff42bb8eea830053f29277ef10c6ae7 /lib/gitlab/database/migration_helpers.rb | |
parent | 7968484dfa363537e6e7822ca1ec100bcd0ec4f8 (diff) | |
download | gitlab-ce-e5c7e11840871e3138ad32693d86de8d7cd7c670.tar.gz |
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.
Diffstat (limited to 'lib/gitlab/database/migration_helpers.rb')
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index dec20d8659b..593ee5d9568 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -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 |