Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e1589a5c
Commit
e1589a5c
authored
Jun 08, 2018
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply feedback
parent
50872bcc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
app/uploaders/object_storage.rb
app/uploaders/object_storage.rb
+11
-2
spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
...ers/workers/object_storage/migrate_uploads_worker_spec.rb
+2
-2
No files found.
app/uploaders/object_storage.rb
View file @
e1589a5c
...
...
@@ -9,7 +9,16 @@ module ObjectStorage
RemoteStoreError
=
Class
.
new
(
StandardError
)
UnknownStoreError
=
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
...
...
@@ -379,7 +388,7 @@ module ObjectStorage
def
with_exclusive_lease
lease_key
=
exclusive_lease_key
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
ensure
...
...
spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
View file @
e1589a5c
...
...
@@ -129,7 +129,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
describe
"limits N+1 queries"
do
let!
(
:projects
)
{
create_list
(
:project
,
10
,
:with_avatar
)
}
it
do
it
"to N*
#{
MIGRATION_QUERIES
}
"
do
query_count
=
ActiveRecord
::
QueryRecorder
.
new
{
perform
(
uploads
)
}
more_projects
=
create_list
(
:project
,
100
,
:with_avatar
)
...
...
@@ -158,7 +158,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
describe
"limits N+1 queries"
do
let!
(
:projects
)
{
create_list
(
:project
,
10
)
}
it
do
it
"to N*
#{
MIGRATION_QUERIES
}
"
do
query_count
=
ActiveRecord
::
QueryRecorder
.
new
{
perform
(
uploads
)
}
more_projects
=
create_list
(
:project
,
100
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment