summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-14 12:48:11 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-14 12:55:52 +0200
commit39b96f02dca3d6edac40b94bf003e6735c4c2524 (patch)
tree1bf0377a3e53fa95451a5f0d34a6de3a56035d90 /lib/gitlab/background_migration.rb
parentbeffbc8aa2845d7a2859c269fd2c891cddb308e6 (diff)
downloadgitlab-ce-39b96f02dca3d6edac40b94bf003e6735c4c2524.tar.gz
Avoid race condition when stealing a background migration
We first pop a job from the Sidekiq queue / scheduled set and only if this has been successfully deleted we process the job. This makes it possible to minimize a possibility of a race condition happening.
Diffstat (limited to 'lib/gitlab/background_migration.rb')
-rw-r--r--lib/gitlab/background_migration.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/gitlab/background_migration.rb b/lib/gitlab/background_migration.rb
index e0325c0138e..73d2611e51f 100644
--- a/lib/gitlab/background_migration.rb
+++ b/lib/gitlab/background_migration.rb
@@ -19,9 +19,7 @@ module Gitlab
next unless job.queue == self.queue
next unless migration_class == steal_class
- perform(migration_class, migration_args)
-
- job.delete
+ perform(migration_class, migration_args) if job.delete
end
end
end