diff options
-rw-r--r-- | db/post_migrate/20170907170235_delete_conflicting_redirect_routes.rb | 4 | ||||
-rw-r--r-- | spec/migrations/delete_conflicting_redirect_routes_spec.rb | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/db/post_migrate/20170907170235_delete_conflicting_redirect_routes.rb b/db/post_migrate/20170907170235_delete_conflicting_redirect_routes.rb index e2e1cddd9e8..3e84b295be4 100644 --- a/db/post_migrate/20170907170235_delete_conflicting_redirect_routes.rb +++ b/db/post_migrate/20170907170235_delete_conflicting_redirect_routes.rb @@ -6,6 +6,8 @@ class DeleteConflictingRedirectRoutes < ActiveRecord::Migration DOWNTIME = false MIGRATION = 'DeleteConflictingRedirectRoutesRange'.freeze + BATCH_SIZE = 200 # At 200, I expect under 20s per batch, which is under our query timeout of 60s. + DELAY_INTERVAL = 12.seconds disable_ddl_transaction! @@ -18,7 +20,7 @@ class DeleteConflictingRedirectRoutes < ActiveRecord::Migration def up say opening_message - queue_background_migration_jobs_by_range_at_intervals(Route, MIGRATION, 1.minute) + queue_background_migration_jobs_by_range_at_intervals(Route, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) end def down diff --git a/spec/migrations/delete_conflicting_redirect_routes_spec.rb b/spec/migrations/delete_conflicting_redirect_routes_spec.rb index cf872595f21..1df2477da51 100644 --- a/spec/migrations/delete_conflicting_redirect_routes_spec.rb +++ b/spec/migrations/delete_conflicting_redirect_routes_spec.rb @@ -10,7 +10,7 @@ describe DeleteConflictingRedirectRoutes, :migration, :sidekiq do end before do - stub_const("Gitlab::Database::MigrationHelpers::BACKGROUND_MIGRATION_BATCH_SIZE", 2) + stub_const("DeleteConflictingRedirectRoutes::BATCH_SIZE", 2) stub_const("Gitlab::Database::MigrationHelpers::BACKGROUND_MIGRATION_JOB_BUFFER_SIZE", 2) routes.create!(id: 1, source_id: 1, source_type: 'Namespace', path: 'foo1') @@ -38,11 +38,11 @@ describe DeleteConflictingRedirectRoutes, :migration, :sidekiq do migrate! expect(BackgroundMigrationWorker.jobs[0]['args']).to eq([described_class::MIGRATION, [1, 2]]) - expect(BackgroundMigrationWorker.jobs[0]['at']).to eq(1.minute.from_now.to_f) + expect(BackgroundMigrationWorker.jobs[0]['at']).to eq(12.seconds.from_now.to_f) expect(BackgroundMigrationWorker.jobs[1]['args']).to eq([described_class::MIGRATION, [3, 4]]) - expect(BackgroundMigrationWorker.jobs[1]['at']).to eq(2.minutes.from_now.to_f) + expect(BackgroundMigrationWorker.jobs[1]['at']).to eq(24.seconds.from_now.to_f) expect(BackgroundMigrationWorker.jobs[2]['args']).to eq([described_class::MIGRATION, [5, 5]]) - expect(BackgroundMigrationWorker.jobs[2]['at']).to eq(3.minutes.from_now.to_f) + expect(BackgroundMigrationWorker.jobs[2]['at']).to eq(36.seconds.from_now.to_f) expect(BackgroundMigrationWorker.jobs.size).to eq 3 end end |