BackfillDraftStatusOnMergeRequests is not running properly on 14.1.8

Summary

We have a customer where they upgraded to GitLab 14.1.8. It appears that BackfillDraftStatusOnMergeRequests is stuck into Pending even though there are eligible MRs for this migration.

rb(main):006:0> MergeRequest.where(state_id: 1).where(draft: false).where("title ~* ?", '^\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP').count
11

Running the migration manually in Rails console results into it returning nil:

irb(main):006:0> Gitlab::BackgroundMigration.perform("BackfillDraftStatusOnMergeRequests", [3936, 111196])
nil

As a workaround, we manually performed the migration:

MergeRequest.where(state_id: 1).where(draft: false).where("title ~* ?", '^\\[draft\\]|\\(draft\\)|draft:|draft|\\[WIP\\]|WIP:|WIP').update_all(draft: true)

and mark the migration as complete:

Gitlab::Database::BackgroundMigrationJob.pending.where(class_name: "BackfillDraftStatusOnMergeRequests").find_each do |job|
  puts Gitlab::Database::BackgroundMigrationJob.mark_all_as_succeeded("BackfillDraftStatusOnMergeRequests", job.arguments)
end

Steps to reproduce

It appears that this is a known issue in GitLab 14.2.0, but it appears to happen to 14.1.8 as well.

I'm also trying to reproduce it on my end.

Example Project

What is the current bug behavior?

BackfillDraftStatusOnMergeRequests is not completing on 14.1.8.

What is the expected correct behavior?

BackfillDraftStatusOnMergeRequests should run properly

Edited Oct 14, 2023 by Julian Paul Dasmarinas
Assignee Loading
Time tracking Loading