diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-07 15:44:47 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-07 15:45:32 +0200 |
commit | c467451ea6f39f498b458e11b5f8a74c53d3541d (patch) | |
tree | 886bb9516b45fa738fc83f278a365cac92b8cc07 /db | |
parent | b41b4d2e6a44a04fc3e6fff09cf45f93033ff0ad (diff) | |
download | gitlab-ce-c467451ea6f39f498b458e11b5f8a74c53d3541d.tar.gz |
Schedule stage_id bg migrations in batches of 10
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb index 107a5661329..5b1ff9b8849 100644 --- a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb +++ b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb @@ -3,6 +3,7 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration DOWNTIME = false BATCH_SIZE = 10000 + RANGE_SIZE = 1000 MIGRATION = 'MigrateBuildStageIdReference'.freeze disable_ddl_transaction! @@ -17,10 +18,12 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration # def up Build.all.each_batch(of: BATCH_SIZE) do |relation, index| - range = relation.pluck('MIN(id)', 'MAX(id)').first - schedule = index * 2.minutes + relation.each_batch(of: RANGE_SIZE) do |relation| + range = relation.pluck('MIN(id)', 'MAX(id)').first - BackgroundMigrationWorker.perform_in(schedule, MIGRATION, range) + BackgroundMigrationWorker + .perform_in(index * 2.minutes, MIGRATION, range) + end end end |