Commit ff949207 authored by Andreas Brandl's avatar Andreas Brandl

Merge branch 'fix_migration_helpers_final_delay' into 'master'

Fix final_delay exception in MigrationHelpers

See merge request gitlab-org/gitlab!30018
parents 106260b1 e65dd345
...@@ -1090,7 +1090,7 @@ into similar problems in the future (e.g. when new tables are created). ...@@ -1090,7 +1090,7 @@ into similar problems in the future (e.g. when new tables are created).
delay_interval = BackgroundMigrationWorker.minimum_interval delay_interval = BackgroundMigrationWorker.minimum_interval
end end
final_delay = nil final_delay = 0
model_class.each_batch(of: batch_size) do |relation, index| model_class.each_batch(of: batch_size) do |relation, index|
start_id, end_id = relation.pluck(Arel.sql('MIN(id), MAX(id)')).first start_id, end_id = relation.pluck(Arel.sql('MIN(id), MAX(id)')).first
......
...@@ -1373,6 +1373,14 @@ describe Gitlab::Database::MigrationHelpers do ...@@ -1373,6 +1373,14 @@ describe Gitlab::Database::MigrationHelpers do
end end
end end
it 'returns zero when nothing gets queued' do
Sidekiq::Testing.fake! do
final_delay = model.queue_background_migration_jobs_by_range_at_intervals(User.none, 'FooJob', 10.minutes)
expect(final_delay).to eq(0)
end
end
context 'with batch_size option' do context 'with batch_size option' do
it 'queues jobs correctly' do it 'queues jobs correctly' do
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
......
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