diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-06-10 13:25:51 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-06-10 13:35:11 -0300 |
commit | 304b43a6227733d9326bca3a379c9588cbe93a8d (patch) | |
tree | 904b17b33f86670a185ffd4785d36049bf897958 /db | |
parent | 65be6f1abf18c0ef5cc91d4af0b1212fa3b9fc52 (diff) | |
download | gitlab-ce-304b43a6227733d9326bca3a379c9588cbe93a8d.tar.gz |
Avoid DB timeouts when scheduling migrations
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20190528180441_enqueue_reset_merge_status.rb | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/db/post_migrate/20190528180441_enqueue_reset_merge_status.rb b/db/post_migrate/20190528180441_enqueue_reset_merge_status.rb index 1b668d85bac..a3d2f497806 100644 --- a/db/post_migrate/20190528180441_enqueue_reset_merge_status.rb +++ b/db/post_migrate/20190528180441_enqueue_reset_merge_status.rb @@ -16,15 +16,10 @@ class EnqueueResetMergeStatus < ActiveRecord::Migration[5.1] def up say 'Scheduling `ResetMergeStatus` jobs' - # We currently have around 135_000 opened, mergeable MRs in GitLab.com. This iteration - # will schedule around 13 batches of 10_000 MRs, which should take around 1 hour to - # complete. - relation = MergeRequest.where(state: 'opened', merge_status: 'can_be_merged') - - relation.each_batch(of: BATCH_SIZE) do |batch, index| - range = batch.pluck('MIN(id)', 'MAX(id)').first - - BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, range) - end + # We currently have more than ~5_000_000 merge request records on GitLab.com. + # This means it'll schedule ~500 jobs (10k MRs each) with a 5 minutes gap, + # so this should take ~41 hours for all background migrations to complete. + # ((5_000_000 / 10_000) * 5) / 60 => 41.6666.. + queue_background_migration_jobs_by_range_at_intervals(MergeRequest, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) end end |