summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-13 11:44:52 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-13 11:44:52 +0200
commit2a0ead2c4730110c898127660fe6600155539f0c (patch)
tree35d9ac1ab2f78a227e6bfeb542c309711bb3d558 /lib/gitlab/background_migration.rb
parent388abbd10c043b4cc406fa717e05dd81b0858c02 (diff)
downloadgitlab-ce-2a0ead2c4730110c898127660fe6600155539f0c.tar.gz
Implement draining scheduled sets of background migrations
Diffstat (limited to 'lib/gitlab/background_migration.rb')
-rw-r--r--lib/gitlab/background_migration.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/gitlab/background_migration.rb b/lib/gitlab/background_migration.rb
index 6ddffe70da4..73688421e74 100644
--- a/lib/gitlab/background_migration.rb
+++ b/lib/gitlab/background_migration.rb
@@ -1,7 +1,7 @@
module Gitlab
module BackgroundMigration
def self.queue
- BackgroundMigrationWorker.sidekiq_options['queue']
+ @queue ||= BackgroundMigrationWorker.sidekiq_options['queue']
end
# Begins stealing jobs from the background migrations queue, blocking the
@@ -9,16 +9,20 @@ module Gitlab
#
# steal_class - The name of the class for which to steal jobs.
def self.steal(steal_class)
- queue = Sidekiq::Queue.new(self.queue)
+ enqueued = Sidekiq::Queue.new(self.queue)
+ scheduled = Sidekiq::ScheduledSet.new
- queue.each do |job|
- migration_class, migration_args = job.args
+ [scheduled, enqueued].each do |queue|
+ queue.each do |job|
+ migration_class, migration_args = job.args
- next unless migration_class == steal_class
+ next unless job.queue == self.queue
+ next unless migration_class == steal_class
- perform(migration_class, migration_args)
+ perform(migration_class, migration_args)
- job.delete
+ job.delete
+ end
end
end
@@ -28,6 +32,7 @@ module Gitlab
# arguments - The arguments to pass to the background migration's "perform"
# method.
def self.perform(class_name, arguments)
+ puts class_name
const_get(class_name).new.perform(*arguments)
end
end