Commit e1589a5c authored by Micaël Bergeron's avatar Micaël Bergeron

apply feedback

parent 50872bcc
...@@ -9,7 +9,16 @@ module ObjectStorage ...@@ -9,7 +9,16 @@ module ObjectStorage
RemoteStoreError = Class.new(StandardError) RemoteStoreError = Class.new(StandardError)
UnknownStoreError = Class.new(StandardError) UnknownStoreError = Class.new(StandardError)
ObjectStorageUnavailable = Class.new(StandardError) ObjectStorageUnavailable = Class.new(StandardError)
ExclusiveLeaseTaken = Class.new(StandardError)
class ExclusiveLeaseTaken < StandardError
def initialize(lease_key)
@lease_key = lease_key
end
def message
"Exclusive lease #{@lease_key} already taken."
end
end
TMP_UPLOAD_PATH = 'tmp/uploads'.freeze TMP_UPLOAD_PATH = 'tmp/uploads'.freeze
...@@ -379,7 +388,7 @@ module ObjectStorage ...@@ -379,7 +388,7 @@ module ObjectStorage
def with_exclusive_lease def with_exclusive_lease
lease_key = exclusive_lease_key lease_key = exclusive_lease_key
uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: 1.hour.to_i).try_obtain uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: 1.hour.to_i).try_obtain
raise ExclusiveLeaseTaken, "Exclusive lease #{lease_key} already taken." unless uuid raise ExclusiveLeaseTaken.new(lease_key) unless uuid
yield uuid yield uuid
ensure ensure
......
...@@ -129,7 +129,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do ...@@ -129,7 +129,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
describe "limits N+1 queries" do describe "limits N+1 queries" do
let!(:projects) { create_list(:project, 10, :with_avatar) } let!(:projects) { create_list(:project, 10, :with_avatar) }
it do it "to N*#{MIGRATION_QUERIES}" do
query_count = ActiveRecord::QueryRecorder.new { perform(uploads) } query_count = ActiveRecord::QueryRecorder.new { perform(uploads) }
more_projects = create_list(:project, 100, :with_avatar) more_projects = create_list(:project, 100, :with_avatar)
...@@ -158,7 +158,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do ...@@ -158,7 +158,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
describe "limits N+1 queries" do describe "limits N+1 queries" do
let!(:projects) { create_list(:project, 10) } let!(:projects) { create_list(:project, 10) }
it do it "to N*#{MIGRATION_QUERIES}" do
query_count = ActiveRecord::QueryRecorder.new { perform(uploads) } query_count = ActiveRecord::QueryRecorder.new { perform(uploads) }
more_projects = create_list(:project, 100) more_projects = create_list(:project, 100)
......
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