diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build_trace_chunk.rb | 2 | ||||
-rw-r--r-- | app/services/concerns/exclusive_lease_lock.rb | 22 |
2 files changed, 1 insertions, 23 deletions
diff --git a/app/models/ci/build_trace_chunk.rb b/app/models/ci/build_trace_chunk.rb index b724d0cb517..43bede7638c 100644 --- a/app/models/ci/build_trace_chunk.rb +++ b/app/models/ci/build_trace_chunk.rb @@ -1,7 +1,7 @@ module Ci class BuildTraceChunk < ActiveRecord::Base include FastDestroyAll - include ExclusiveLeaseLock + include ::Gitlab::ExclusiveLeaseHelpers extend Gitlab::Ci::Model belongs_to :build, class_name: "Ci::Build", foreign_key: :build_id diff --git a/app/services/concerns/exclusive_lease_lock.rb b/app/services/concerns/exclusive_lease_lock.rb deleted file mode 100644 index 8da54b0d15d..00000000000 --- a/app/services/concerns/exclusive_lease_lock.rb +++ /dev/null @@ -1,22 +0,0 @@ -module ExclusiveLeaseLock - extend ActiveSupport::Concern - - FailedToObtainLockError = Class.new(StandardError) - - def in_lock(key, ttl: 1.minute, retries: 10, sleep_sec: 0.01.seconds) - lease = Gitlab::ExclusiveLease.new(key, timeout: ttl) - - until uuid = lease.try_obtain - # Keep trying until we obtain the lease. To prevent hammering Redis too - # much we'll wait for a bit. - sleep(sleep_sec) - break if (retries -= 1) < 0 - end - - raise FailedToObtainLockError, 'Failed to obtain a lock' unless uuid - - return yield - ensure - Gitlab::ExclusiveLease.cancel(key, uuid) - end -end |