diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2018-08-11 01:45:46 +0200 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2018-08-11 04:15:59 +0200 |
commit | f21e655b61725b972ae80d584a66d6deb53a337d (patch) | |
tree | f9fb191d364e30119eb7c02f65e4eef12936a232 /db/migrate | |
parent | f6d47d0dee0cbbb49f778de9d196c3dae0dbce7f (diff) | |
download | gitlab-ce-f21e655b61725b972ae80d584a66d6deb53a337d.tar.gz |
disable_statement_timeout doesn't require any argument anymore
it will decide the method for disable statement_timeout upon
per transaction or per session, based on how it's called.
When calling with a block, block will be executed and it will use
session based statement_timeout, otherwise will default to existing
behavior.
Diffstat (limited to 'db/migrate')
8 files changed, 23 insertions, 23 deletions
diff --git a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb index 35e95e6b80a..12352d98a62 100644 --- a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb +++ b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb @@ -106,7 +106,7 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration # Disables statement timeouts for the current connection. This is # necessary as removing of orphaned data might otherwise exceed the # statement timeout. - disable_statement_timeout(transaction: false) do + disable_statement_timeout do remove_orphans(*queue.pop) until queue.empty? steal_from_queues(queues - [queue]) diff --git a/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb b/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb index 28f36e8bf18..a770ff63b4e 100644 --- a/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb +++ b/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb @@ -25,7 +25,7 @@ class AddLowerPathIndexToRedirectRoutes < ActiveRecord::Migration # trivial to write a query that checks for an index. BUT there is a # convenient `IF EXISTS` parameter for `DROP INDEX`. if supports_drop_index_concurrently? - disable_statement_timeout(transaction: false) do + disable_statement_timeout do execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME};" end else diff --git a/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb b/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb index 1c14f274b8b..130b24fe6f0 100644 --- a/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb +++ b/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb @@ -8,7 +8,7 @@ class AddIndexOnNamespacesLowerName < ActiveRecord::Migration def up return unless Gitlab::Database.postgresql? - disable_statement_timeout(transaction: false) do + disable_statement_timeout do if Gitlab::Database.version.to_f >= 9.5 # Allow us to hot-patch the index manually ahead of the migration execute "CREATE INDEX CONCURRENTLY IF NOT EXISTS #{INDEX_NAME} ON namespaces (lower(name));" @@ -21,7 +21,7 @@ class AddIndexOnNamespacesLowerName < ActiveRecord::Migration def down return unless Gitlab::Database.postgresql? - disable_statement_timeout(transaction: false) do + disable_statement_timeout do if Gitlab::Database.version.to_f >= 9.2 execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME};" else diff --git a/db/migrate/20180113220114_rework_redirect_routes_indexes.rb b/db/migrate/20180113220114_rework_redirect_routes_indexes.rb index 7748104f436..53f82a31203 100644 --- a/db/migrate/20180113220114_rework_redirect_routes_indexes.rb +++ b/db/migrate/20180113220114_rework_redirect_routes_indexes.rb @@ -18,7 +18,7 @@ class ReworkRedirectRoutesIndexes < ActiveRecord::Migration OLD_INDEX_NAME_PATH_LOWER = "index_on_redirect_routes_lower_path" def up - disable_statement_timeout(transaction: false) do + disable_statement_timeout do # this is a plain btree on a single boolean column. It'll never be # selective enough to be valuable. This class is called by # setup_postgresql.rake so it needs to be able to handle this @@ -29,7 +29,7 @@ class ReworkRedirectRoutesIndexes < ActiveRecord::Migration # If we're on MySQL then the existing index on path is ok. But on # Postgres we need to clean things up: - return unless Gitlab::Database.postgresql? + break unless Gitlab::Database.postgresql? if_not_exists = Gitlab::Database.version.to_f >= 9.5 ? "IF NOT EXISTS" : "" @@ -52,10 +52,10 @@ class ReworkRedirectRoutesIndexes < ActiveRecord::Migration end def down - disable_statement_timeout(transaction: false) do + disable_statement_timeout do add_concurrent_index(:redirect_routes, :permanent) - return unless Gitlab::Database.postgresql? + break unless Gitlab::Database.postgresql? execute("CREATE INDEX CONCURRENTLY #{OLD_INDEX_NAME_PATH_TPOPS} ON redirect_routes (path varchar_pattern_ops);") execute("CREATE INDEX CONCURRENTLY #{OLD_INDEX_NAME_PATH_LOWER} ON redirect_routes (LOWER(path));") diff --git a/db/migrate/20180403035759_create_project_ci_cd_settings.rb b/db/migrate/20180403035759_create_project_ci_cd_settings.rb index 61b43ef2038..173e662cffc 100644 --- a/db/migrate/20180403035759_create_project_ci_cd_settings.rb +++ b/db/migrate/20180403035759_create_project_ci_cd_settings.rb @@ -13,7 +13,7 @@ class CreateProjectCiCdSettings < ActiveRecord::Migration end end - disable_statement_timeout(transaction: false) do + disable_statement_timeout do # This particular INSERT will take between 10 and 20 seconds. execute 'INSERT INTO project_ci_cd_settings (project_id) SELECT id FROM projects' diff --git a/db/migrate/20180420010616_cleanup_build_stage_migration.rb b/db/migrate/20180420010616_cleanup_build_stage_migration.rb index a535bc03194..5e9fe756efd 100644 --- a/db/migrate/20180420010616_cleanup_build_stage_migration.rb +++ b/db/migrate/20180420010616_cleanup_build_stage_migration.rb @@ -14,7 +14,7 @@ class CleanupBuildStageMigration < ActiveRecord::Migration end def up - disable_statement_timeout(transaction: false) do + disable_statement_timeout do ## # We steal from the background migrations queue to catch up with the # scheduled migrations set. @@ -55,7 +55,7 @@ class CleanupBuildStageMigration < ActiveRecord::Migration def down if index_exists_by_name?(:ci_builds, TMP_INDEX) - disable_statement_timeout(transaction: false) do + disable_statement_timeout do remove_concurrent_index_by_name(:ci_builds, TMP_INDEX) end end diff --git a/db/migrate/20180504195842_project_name_lower_index.rb b/db/migrate/20180504195842_project_name_lower_index.rb index 856ccf0620e..74f3673bb03 100644 --- a/db/migrate/20180504195842_project_name_lower_index.rb +++ b/db/migrate/20180504195842_project_name_lower_index.rb @@ -13,7 +13,7 @@ class ProjectNameLowerIndex < ActiveRecord::Migration def up return unless Gitlab::Database.postgresql? - disable_statement_timeout(transaction: false) do + disable_statement_timeout do execute "CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON projects (LOWER(name))" end end @@ -21,7 +21,7 @@ class ProjectNameLowerIndex < ActiveRecord::Migration def down return unless Gitlab::Database.postgresql? - disable_statement_timeout(transaction: false) do + disable_statement_timeout do if supports_drop_index_concurrently? execute "DROP INDEX CONCURRENTLY IF EXISTS #{INDEX_NAME}" else diff --git a/db/migrate/20180702124358_remove_orphaned_routes.rb b/db/migrate/20180702124358_remove_orphaned_routes.rb index 6f6e289ba87..4068e479b6c 100644 --- a/db/migrate/20180702124358_remove_orphaned_routes.rb +++ b/db/migrate/20180702124358_remove_orphaned_routes.rb @@ -28,16 +28,16 @@ class RemoveOrphanedRoutes < ActiveRecord::Migration # which is pretty close to our 15 second statement timeout. To ensure a # smooth deployment procedure we disable the statement timeouts for this # migration, just in case. - disable_statement_timeout - - # On GitLab.com there are around 4000 orphaned project routes, and around - # 150 orphaned namespace routes. - [ - Route.orphaned_project_routes, - Route.orphaned_namespace_routes - ].each do |relation| - relation.each_batch(of: 1_000) do |batch| - batch.delete_all + disable_statement_timeout do + # On GitLab.com there are around 4000 orphaned project routes, and around + # 150 orphaned namespace routes. + [ + Route.orphaned_project_routes, + Route.orphaned_namespace_routes + ].each do |relation| + relation.each_batch(of: 1_000) do |batch| + batch.delete_all + end end end end |