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 ...@@ -376,12 +376,13 @@ module ObjectStorage
end end
def with_exclusive_lease def with_exclusive_lease
uuid = Gitlab::ExclusiveLease.new(exclusive_lease_key, timeout: 1.hour.to_i).try_obtain lease_key = exclusive_lease_key
raise 'exclusive lease already taken' unless uuid uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: 1.hour.to_i).try_obtain
raise "Exclusive lease #{lease_key} already taken." unless uuid
yield uuid yield uuid
ensure ensure
Gitlab::ExclusiveLease.cancel(exclusive_lease_key, uuid) Gitlab::ExclusiveLease.cancel(lease_key, uuid)
end end
# #
......
...@@ -22,7 +22,7 @@ module RecordsUploads ...@@ -22,7 +22,7 @@ module RecordsUploads
Upload.transaction do Upload.transaction do
uploads.where(path: upload_path).delete_all uploads.where(path: upload_path).delete_all
upload.destroy! if upload upload.delete if upload
self.upload = build_upload.tap(&:save!) self.upload = build_upload.tap(&:save!)
end end
......
require 'spec_helper' require 'spec_helper'
MIGRATION_QUERIES = 7 MIGRATION_QUERIES = 5
describe ObjectStorage::MigrateUploadsWorker, :sidekiq do describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
shared_context 'sanity_check! fails' do shared_context 'sanity_check! fails' do
...@@ -14,7 +14,6 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do ...@@ -14,7 +14,6 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
let(:to_store) { ObjectStorage::Store::REMOTE } let(:to_store) { ObjectStorage::Store::REMOTE }
def perform(uploads) def perform(uploads)
binding.pry
described_class.new.perform(uploads.ids, model_class.to_s, mounted_as, to_store) described_class.new.perform(uploads.ids, model_class.to_s, mounted_as, to_store)
rescue ObjectStorage::MigrateUploadsWorker::Report::MigrationFailures rescue ObjectStorage::MigrateUploadsWorker::Report::MigrationFailures
# swallow # 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