diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-05-29 00:28:12 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-05-31 21:21:20 +0300 |
commit | f3efec202986f820eaa1dc76db34b095e73a99f6 (patch) | |
tree | 9a60f451cc22c917083976f63d6d2b288f679557 /db/post_migrate | |
parent | c7e5d046a54cd10145ea81983a7e3ceb94755f79 (diff) |
Reset merge status from mergeable MRs
Adds migrations to reset the merge_status of opened,
mergeable MRs. That's required by
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28513
so we're able to sync the status update along merge-ref,
without leaving MRs with a stale merge-ref.
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20190528180441_enqueue_reset_merge_status.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/db/post_migrate/20190528180441_enqueue_reset_merge_status.rb b/db/post_migrate/20190528180441_enqueue_reset_merge_status.rb new file mode 100644 index 00000000000..1b668d85bac --- /dev/null +++ b/db/post_migrate/20190528180441_enqueue_reset_merge_status.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class EnqueueResetMergeStatus < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 10_000 + MIGRATION = 'ResetMergeStatus' + DELAY_INTERVAL = 5.minutes.to_i + + disable_ddl_transaction! + + 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 + end +end |