blob: de0c357ab1cc160017223d9f3b3e827f62829880 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
# rubocop: disable Style/Documentation
class MergeRequestAssigneesMigrationProgressCheck
include Gitlab::Utils::StrongMemoize
RESCHEDULE_DELAY = 3.hours
WORKER = 'PopulateMergeRequestAssigneesTable'
DeadJobsError = Class.new(StandardError)
def perform
raise DeadJobsError, "Only dead background jobs in the queue for #{WORKER}" if !ongoing? && dead_jobs?
if ongoing?
BackgroundMigrationWorker.perform_in(RESCHEDULE_DELAY, self.class.name)
else
Feature.enable(:multiple_merge_request_assignees)
end
end
private
def dead_jobs?
strong_memoize(:dead_jobs) do
migration_klass.dead_jobs?(WORKER)
end
end
def ongoing?
strong_memoize(:ongoing) do
migration_klass.exists?(WORKER) || migration_klass.retrying_jobs?(WORKER)
end
end
def migration_klass
Gitlab::BackgroundMigration
end
end
# rubocop: enable Style/Documentation
end
end
|