Commit 7b7fb754 authored by Michael Kozono's avatar Michael Kozono

Reduce batch size

…to stay within our query timeout of 60s. Also reduce the job interval to keep the same overall migration time of ~3.3 days.
parent c9232087
...@@ -6,6 +6,8 @@ class DeleteConflictingRedirectRoutes < ActiveRecord::Migration ...@@ -6,6 +6,8 @@ class DeleteConflictingRedirectRoutes < ActiveRecord::Migration
DOWNTIME = false DOWNTIME = false
MIGRATION = 'DeleteConflictingRedirectRoutesRange'.freeze 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! disable_ddl_transaction!
...@@ -18,7 +20,7 @@ class DeleteConflictingRedirectRoutes < ActiveRecord::Migration ...@@ -18,7 +20,7 @@ class DeleteConflictingRedirectRoutes < ActiveRecord::Migration
def up def up
say opening_message 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 end
def down def down
......
...@@ -10,7 +10,7 @@ describe DeleteConflictingRedirectRoutes, :migration, :sidekiq do ...@@ -10,7 +10,7 @@ describe DeleteConflictingRedirectRoutes, :migration, :sidekiq do
end end
before do 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) stub_const("Gitlab::Database::MigrationHelpers::BACKGROUND_MIGRATION_JOB_BUFFER_SIZE", 2)
routes.create!(id: 1, source_id: 1, source_type: 'Namespace', path: 'foo1') routes.create!(id: 1, source_id: 1, source_type: 'Namespace', path: 'foo1')
...@@ -38,11 +38,11 @@ describe DeleteConflictingRedirectRoutes, :migration, :sidekiq do ...@@ -38,11 +38,11 @@ describe DeleteConflictingRedirectRoutes, :migration, :sidekiq do
migrate! migrate!
expect(BackgroundMigrationWorker.jobs[0]['args']).to eq([described_class::MIGRATION, [1, 2]]) 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]['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]['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 expect(BackgroundMigrationWorker.jobs.size).to eq 3
end end
end end
......
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