diff options
author | Robert Speicher <robert@gitlab.com> | 2016-07-15 14:51:20 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-07-15 14:51:20 +0000 |
commit | 8b7932c21951de172d531ab8a3e9506c98db7483 (patch) | |
tree | 4cc514f4a072e5f4e06237735cae4d0339fe0ae1 /lib | |
parent | 7cb51ba5728626433a2620940f969419e1daa895 (diff) | |
parent | 3fd304c1a5063ad9fd53b851de79322f49c68997 (diff) | |
download | gitlab-ce-8b7932c21951de172d531ab8a3e9506c98db7483.tar.gz |
Merge branch 'disable-statement-timeout' into 'master'
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.
See merge request !5263
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index dec20d8659b..927f9dad20b 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -20,11 +20,19 @@ module Gitlab if Database.postgresql? options = options.merge({ algorithm: :concurrently }) + disable_statement_timeout end 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. @@ -133,6 +141,8 @@ module Gitlab 'in the body of your migration class' end + disable_statement_timeout + transaction do add_column(table, column, type, default: nil) |