Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-07 16:44:47 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-07 16:45:32 +0300
commitc467451ea6f39f498b458e11b5f8a74c53d3541d (patch)
tree886bb9516b45fa738fc83f278a365cac92b8cc07 /db/post_migrate
parentb41b4d2e6a44a04fc3e6fff09cf45f93033ff0ad (diff)
Schedule stage_id bg migrations in batches of 10
Diffstat (limited to 'db/post_migrate')
-rw-r--r--db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb9
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