blob: 43a7032e6823dfc8a76f5c95f02e972811dc5ecf (
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
|
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
# A background migration that finished any pending
# MigrateMergeRequestDiffCommitUsers jobs, and schedules new jobs itself.
#
# This migration exists so we can bypass rescheduling issues (e.g. jobs
# getting dropped after too many retries) that may occur when
# MigrateMergeRequestDiffCommitUsers jobs take longer than expected.
class StealMigrateMergeRequestDiffCommitUsers
def perform(start_id, stop_id)
MigrateMergeRequestDiffCommitUsers.new.perform(start_id, stop_id)
schedule_next_job
end
def schedule_next_job
next_job = Database::BackgroundMigrationJob
.for_migration_class('MigrateMergeRequestDiffCommitUsers')
.pending
.first
return unless next_job
BackgroundMigrationWorker.perform_in(
5.minutes,
'StealMigrateMergeRequestDiffCommitUsers',
next_job.arguments
)
end
end
end
end
|