Commit dfef5437 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use a helper to schedule pipeline stages migration

parent 2ee20d5a
......@@ -3,7 +3,7 @@ class ScheduleBuildStageMigration < ActiveRecord::Migration
DOWNTIME = false
MIGRATION = 'MigrateBuildStage'.freeze
BATCH_SIZE = 800
BATCH_SIZE = 500
disable_ddl_transaction!
......@@ -15,10 +15,11 @@ class ScheduleBuildStageMigration < ActiveRecord::Migration
def up
disable_statement_timeout
Build.where('stage_id IS NULL').each_batch(of: BATCH_SIZE) do |builds, index|
builds.pluck('MIN(id)', 'MAX(id)').first.tap do |range|
BackgroundMigrationWorker.perform_in(index * 5.minutes, MIGRATION, range)
end
Build.where('stage_id IS NULL').tap do |relation|
queue_background_migration_jobs_by_range_at_intervals(relation,
MIGRATION,
5.minutes,
batch_size: BATCH_SIZE)
end
end
......
......@@ -35,8 +35,6 @@ module Gitlab
end
def perform(start_id, stop_id)
# TODO, statement timeout?
stages = Migratable::Build.where('stage_id IS NULL')
.where('id BETWEEN ? AND ?', start_id, stop_id)
.map { |build| build.ensure_stage! }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment