Ensure that we cancel the leasing when GeoRepositorySyncWorker finishes

parent 62fb1cd5
...@@ -119,13 +119,15 @@ class GeoRepositorySyncWorker ...@@ -119,13 +119,15 @@ class GeoRepositorySyncWorker
end end
def try_obtain_lease def try_obtain_lease
uuid = Gitlab::ExclusiveLease.new(LEASE_KEY, timeout: LEASE_TIMEOUT).try_obtain lease = Gitlab::ExclusiveLease.new(LEASE_KEY, timeout: LEASE_TIMEOUT).try_obtain
return unless uuid return unless lease
yield begin
yield lease
release_lease(uuid) ensure
Gitlab::ExclusiveLease.cancel(LEASE_KEY, lease)
end
end end
def release_lease(uuid) def release_lease(uuid)
......
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