Commit 44975f8a authored by Micaël Bergeron's avatar Micaël Bergeron

shave off another 20% query

parent 38c2e480
......@@ -376,12 +376,13 @@ module ObjectStorage
end
def with_exclusive_lease
uuid = Gitlab::ExclusiveLease.new(exclusive_lease_key, timeout: 1.hour.to_i).try_obtain
raise 'exclusive lease already taken' unless uuid
lease_key = exclusive_lease_key
uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: 1.hour.to_i).try_obtain
raise "Exclusive lease #{lease_key} already taken." unless uuid
yield uuid
ensure
Gitlab::ExclusiveLease.cancel(exclusive_lease_key, uuid)
Gitlab::ExclusiveLease.cancel(lease_key, uuid)
end
#
......
......@@ -22,7 +22,7 @@ module RecordsUploads
Upload.transaction do
uploads.where(path: upload_path).delete_all
upload.destroy! if upload
upload.delete if upload
self.upload = build_upload.tap(&:save!)
end
......
require 'spec_helper'
MIGRATION_QUERIES = 7
MIGRATION_QUERIES = 5
describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
shared_context 'sanity_check! fails' do
......@@ -14,7 +14,6 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
let(:to_store) { ObjectStorage::Store::REMOTE }
def perform(uploads)
binding.pry
described_class.new.perform(uploads.ids, model_class.to_s, mounted_as, to_store)
rescue ObjectStorage::MigrateUploadsWorker::Report::MigrationFailures
# swallow
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment