diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-06-13 12:45:34 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-06-13 12:45:34 +0300 |
commit | a66af9b121d3f03f46a689cb9bb0867628618974 (patch) | |
tree | d0538dd5c1b3b29365df7662c4e673a7e2afe405 /app/uploaders/object_storage.rb | |
parent | 82c638d9f65db5d1beb6869aaeea01c43cac22d8 (diff) | |
parent | 3961407248c55f0524c8acfa154ace4ed33e087a (diff) |
Merge branch '47513-upload-migration-lease-key-is-incorrect-for-non-mounted-uploaders' into 'master'
Resolve "Upload migration lease key is incorrect for non-mounted uploaders"
Closes #47513
See merge request gitlab-org/gitlab-ce!19600
Diffstat (limited to 'app/uploaders/object_storage.rb')
-rw-r--r-- | app/uploaders/object_storage.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/app/uploaders/object_storage.rb b/app/uploaders/object_storage.rb index c6ea12cbe9d..b8ecfc4ee2b 100644 --- a/app/uploaders/object_storage.rb +++ b/app/uploaders/object_storage.rb @@ -73,6 +73,15 @@ module ObjectStorage upload.id) end + def exclusive_lease_key + # For FileUploaders, model may have many uploaders. In that case + # we want to use exclusive key per upload, not per model to allow + # parallel migration + key_object = upload || model + + "object_storage_migrate:#{key_object.class}:#{key_object.id}" + end + private def current_upload_satisfies?(paths, model) @@ -316,6 +325,10 @@ module ObjectStorage super end + def exclusive_lease_key + "object_storage_migrate:#{model.class}:#{model.id}" + end + private def schedule_background_upload? @@ -382,10 +395,6 @@ module ObjectStorage end end - def exclusive_lease_key - "object_storage_migrate:#{model.class}:#{model.id}" - end - def with_exclusive_lease lease_key = exclusive_lease_key uuid = Gitlab::ExclusiveLease.new(lease_key, timeout: 1.hour.to_i).try_obtain |